How can I add data to an existing PowerPoint presentation using Node? - node.js

I have a PowerPoint template with placeholder data. I need to swap out the placeholder text with some numbers using Node, but I'm having trouble finding a package that supports this. Has anyone seen anything along these lines?

Have you looked into the PowerPoint JavaScript API?
For example:
Call the ShapeCollection.getItem(key) method to get your Shape object
Update the text value via Shape.textFrame.textRange.text
Related example from Microsoft's docs:
// This sample creates a light blue rectangle with braces ("{}") on the left and right ends
// and adds the purple text "Shape text" to the center.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.slides.getItemAt(0).shapes;
const braces = shapes.addGeometricShape(PowerPoint.GeometricShapeType.bracePair);
braces.left = 100;
braces.top = 400;
braces.height = 50;
braces.width = 150;
braces.name = "Braces";
braces.fill.setSolidColor("lightblue");
braces.textFrame.textRange.text = "Shape text";
braces.textFrame.textRange.font.color = "purple";
braces.textFrame.verticalAlignment = PowerPoint.TextVerticalAlignment.middleCentered;
await context.sync();
});

Related

Displaying a DICOM dataset as 3D representation

I am trying to show a DICOM Series as a 3D representation. It worked with a different set of data but with the current one, the 3D image does not show up. The output values in the datastack of windowCenter and windowWidth are -964 and -664. I am using the latest version of AMI.js but still cannot display the DICOMs as 3D.
Do I have to convert the negativ values somehow, so that they turn out as positive values? Or do you have any other idea why I cannot display the Data?
I am loading the Data with the AMI.VolumeLoader, here is the important bit of code:
let loader = new AMI.VolumeLoader();
loader.load(files)
.then(() => {
let series = loader.data[0].mergeSeries(loader.data)[0];
loader.free();
loader = null;
let stack = series.stack[0];
//stack Helper
vrHelper = new AMI.VolumeRenderingHelper(stack);
scene.add(vrHelper);
//LUT
lut = new AMI.LutHelper('lut-canvases');
lut.luts = AMI.LutHelper.presetLuts();
lut.lutsO = AMI.LutHelper.presetLutsO();
//update related uniforms
vrHelper.uniforms.uTextureLUT.value = lut.texture;
vrHelper.uniforms.uLut.value = 1;
// camera
let centerLPS = stack.worldCenter();
camera.lookAt(centerLPS.x, centerLPS.y, centerLPS.z);
camera.updateProjectionMatrix();
controls.target.set(centerLPS.x, centerLPS.y, centerLPS.z);
})
.catch((error) => window.console.log(error));
A different set of Data is showing as it should be:
The other set of data is just not showing up and I don't even get an error message.

Change color instead of background color of text in etherpad

I am trying to find solution for "Authorship color" in etherpad. People who never used etherpad, please ignore this question as they will not understand.
So normally "Authorship Color" is the color provided as a background-color of the text and it can be given as parameter when initializing the pad. It helps recognizing who has written what in pad.
I want to have white background for all text and change the text-color instead of background color depending upon the user. So its like if I provided red color when initializing the pad, I want to have red writing in pad instead of red background and white writing in pad(as usual).
Please dont put this question on hold as I dont have any specific code to provide related to this problem. Ask in comment instead, i will clear whatever is not understandable.
Thanks,
First of all, Thanks to everyone for not blocking or making this question on Post as no piece of code was provided.
I was about to put bounty on this question when I decided to try myself one more time and well I have resolved the problem after going through a lot. Though, it helped me understand etherpad better.
I want to list two important links related to etherpad:
https://github.com/ether/etherpad-lite/wiki
About src - https://github.com/ether/etherpad-lite/wiki/Introduction-to-the-source
They can be very important if you are trying to understand etherpad or want to do some modification yourself.
So here is how you do it:
In src/static/js/ace2_inner.js , go to setAuthorStyle function and Replace:
// author color
authorStyle.backgroundColor = bgcolor;
parentAuthorStyle.backgroundColor = bgcolor;
// text contrast
if(colorutils.luminosity(colorutils.css2triple(bgcolor)) < 0.5)
{
authorStyle.color = '#ffffff';
parentAuthorStyle.color = '#ffffff';
}else{
authorStyle.color = null;
parentAuthorStyle.color = null;
}
// anchor text contrast
if(colorutils.luminosity(colorutils.css2triple(bgcolor)) < 0.55)
{
anchorStyle.color = colorutils.triple2css(colorutils.complementary(colorutils.css2triple(bgcolor)));
}else{
anchorStyle.color = null;
}
With:
authorStyle.backgroundColor = '#ffffff';
parentAuthorStyle.backgroundColor = '#ffffff';
authorStyle.color = bgcolor;
parentAuthorStyle.color = bgcolor;
And comment Out:
if ((typeof info.fade) == "number")
{
bgcolor = fadeColor(bgcolor, info.fade);
}
Ofcource dont forget to restart process by bin/run.sh for changes to take place.
People, who are interested to understand how it works can keep reading.
So etherpad receives parameters with which etherpad has been initialized in src/static/js/pad.js so if you have defined: 'userColor' when you have initialized the pad, it will go in globalUserColor in mentioned file.
Then this variable globalUserColor populates pad.myUserInfo.colorId in same file.
Now in collab_client.js , this colorId gets stored in cssColor in function tellAceAuthorInfo and editor.setAuthorInfo is being called by giving parameter bgcolor: cssColor.
Now this function setAuthorInfo exists in src/static/js/ace2_inner.js which calls to other native function(same file) setAuthorStyle where we have made changes.
What I did is that instead of changing background color with provided variable bgcolor which actually holds userColor :
authorStyle.backgroundColor = bgcolor;
parentAuthorStyle.backgroundColor = bgcolor;
I changed backgroundColor to white(#ffffff) and color of text to bgcolor :
authorStyle.backgroundColor = '#ffffff';
parentAuthorStyle.backgroundColor = '#ffffff';
authorStyle.color = bgcolor;
parentAuthorStyle.color = bgcolor;
I also deleted:
// text contrast
if(colorutils.luminosity(colorutils.css2triple(bgcolor)) < 0.5)
{
authorStyle.color = '#ffffff';
parentAuthorStyle.color = '#ffffff';
}else{
authorStyle.color = null;
parentAuthorStyle.color = null;
}
// anchor text contrast
if(colorutils.luminosity(colorutils.css2triple(bgcolor)) < 0.55)
{
anchorStyle.color = colorutils.triple2css(colorutils.complementary(colorutils.css2triple(bgcolor)));
}else{
anchorStyle.color = null;
}
Because, these lines set the contrast of text color depending upon the background chosen color. But I have made background white and set text color to given userColor so I don't need the contrast functionality anymore.
Ultimately I also commented:
if ((typeof info.fade) == "number")
{
bgcolor = fadeColor(bgcolor, info.fade);
}
Because it makes the text fade when user is not online, at least for me it did.
So that's it. I hope it will help someone who wants same functionality as I did.

OpenXml - How to remove lines between points in a scatterChart

I have plotted a scatterChart in an Excel file using OpenXml. The points are joined by line. How can I remove the line? I tried doing this:
ScatterStyle scatterStyle = new ScatterStyle() { Val = ScatterStyleValues.Marker };
scatterchart.AppendChild<ScatterStyle>(scatterStyle);
But Excel repairs the file and changes the value back to ScatterStyleValues.LineMarker from ScatterStyleValues.Marker.
Please help me. Thankyou
It turns out that you have to add a shape property to your series, and add an outline where fill = nofill.
enter code here
//ChartShapeProperty of series
ChartShapeProperties SeriesShapeProperty = new DocumentFormat.OpenXml.Drawing.Charts.ChartShapeProperties();
DocumentFormat.OpenXml.Drawing.Outline outline = new DocumentFormat.OpenXml.Drawing.Outline(new DocumentFormat.OpenXml.Drawing.NoFill()) { Width = 28575 };
SeriesShapeProperty.Append(outline);
scatterChartSeries.Append(SeriesShapeProperty);

(THREE.js) Material isn't working on my custom THREE.Geometry shape

I created a triangle and I am trying to make it red. However it remains black. The problem doesn't seem to be the material as it works on other Geometries I've made.
Here is my triangle:
var triangle = new THREE.Geometry();
triangle.vertices.push(
new THREE.Vector3(-10,10,0),
new THREE.Vector3(-10,-10,0),
new THREE.Vector3(10,-10,0)
);
triangle.faces.push(new THREE.Face3(0,1,2));
triangle.computeBoundingSphere();
this.redtriangle = new THREE.Mesh(triangle, this.redMat)
I tried some suggestions online to color it using:
triangle.faces.push(new THREE.Face3(0,1,2));
triangle.faces[0].vertexColors[0] = new THREE.Color(0xFF0000);
triangle.faces[0].vertexColors[1] = new THREE.Color(0xFF0000);
triangle.faces[0].vertexColors[2] = new THREE.Color(0xFF0000);
My material
this.redMat = new THREE.MeshLambertMaterial ({
color: 0xFF0000,
shading:THREE.FlatShading,
// I added this line for the suggestion above
// vertexColors:THREE.VertexColors,
side:THREE.DoubleSide
})
I've also tried to insert
triangle.colorsNeedUpdate = true;
or
geometry.colorsNeedsUpdate = true;
but no matter what variations/where I put it, it doesn't want to work. The triangle stays black.
Your vertices definition is in clockwise order when it should have been counter-clockwise. So if you change your new THREE.Face3(0,1,2) to new THREE.Face3(0,2,1) you should see something.

iTextSharp pdf table cell height issue

I have iTextSharp 5.4.4 (nuget) and have a nice table with a barcode (ean13) and text below it.
I have specific tablecell heights (and cell widths) because I want to print the pdf to an A4 with stickers.
Here is the current layout:
as you can see, there is a rather large gap between the ean13 code and the text below.
here is my C# code:
PdfPCell c = new PdfPCell();
c.FixedHeight = 21.2f * postScriptPointsPerMilimeter; // to get to accurate milimeters
c.HorizontalAlignment = Element.ALIGN_CENTER;
Paragraph p = new Paragraph();
p.Font.Size = 6;
Chunk code = new Chunk(dr["productcode"].ToString());
p.Alignment = Element.ALIGN_CENTER;
p.Add(code);
BarcodeEAN ean13 = new BarcodeEAN();
ean13.CodeType = BarcodeEAN.EAN13;
ean13.Code = dr["ProductEan13"].ToString();
ean13.BarHeight = 4.0f * postScriptPointsPerMilimeter;
var a = ean13.CreateImageWithBarcode(cb, null, null);
a.ScalePercent(90);
c.AddElement(a);
c.AddElement(p);
t.AddCell(c);
My question is to reduce the space between the barcode and the text. I cannot see if it has something to do with the barcode's margins or the paragraph's or maybe both... hard to troubleshoot.
p.Leading = 0;
That was missing. I thought that
p.SpacingBefore = 0;
would do the trick, but it didn't. Leading did!

Resources