@arun08,
Thank you for the code example. Could you please also share a code that calls the function fillImageBase64PlaceHolder
and presentation file you used?
function fillPlaceHolderAsPerType(
shape: any,
placeHolder: IPlaceHolder,
presentation: any
) {
switch (placeHolder.type) {
case PlaceHolderType.Text:
fillTextPlaceHolder(shape, placeHolder);
break;
case PlaceHolderType.Doughnut:
fillDoughnutPlaceHolder(shape, placeHolder);
break;
case PlaceHolderType.Line:
case PlaceHolderType.LineWithMarker:
fillLinePlaceHolder(shape, placeHolder);
break;
case PlaceHolderType.Map:
fillMapPlaceHolder(shape, placeHolder);
break;
case PlaceHolderType.ImageBase64:
fillImageBase64PlaceHolder(shape, placeHolder, presentation);
break;
default:
console.log("Placeholder not matched", placeHolder);
}
}
unable to upload the pptx file here
new_template_file.zip (203.9 KB)
This is something which I want to implement, because I don’t want to store multiple images in my server which will cause overhead in storage and retrieval. Kindly do the needful. Even if you have a sample code (complete code) which can accommodate this will be good.
thank you for taking this on priority.
@arun08,
Thank you for your patience. Unfortunately, I was unable to reproduce the error you described. Could you please check the error using the latest version of Aspose.Slides for Node.js?
Can you share your code sample which i can take reference and check ??
That way i can run that in local and make the final decision
@andrey.potapov , but it does not have any import statement and the calling function etc. which can give me insights on what i am missing. Can you share the entire stuff ? Since i am unable to do it in my local ?
Thanks in advance.
@arun08,
Please try using the following code example:
var aspose = aspose || {};
const java = require("java");
const { Readable } = require("stream");
const asposeSlides = require("aspose.slides.via.java");
const base64Image = "data:image/png;base64,..." // use valid data here
var presentation = new asposeSlides.Presentation();
const [, encodedData] = base64Image.split(',');
const imageBytes = Buffer.from(encodedData, 'base64');
const imageStream = new Readable();
imageStream.push(imageBytes);
imageStream.push(null);
asposeSlides.readBytesFromStream(imageStream, function (imgArray) {
// ...
});
presentation.dispose();
thanks, will try this and get back.
@andrey.potapov thanks for the help, I was able to add the image in the new presentation but it displayed only half of the real image also i have a template where i have an sample image i am trying to replace or add the base64 image in that place, is it possible to do ?
@arun08,
It looks like you have two issues.
Please share the following files:
- sample presentation file
- input image file
- output presentation file
Then we will check the problem and help you.
I am working on the question and will get back to you soon.
TemplateFile.zip (406.0 KB)
I have added the sample image file, the requirement is to add base64 image data into the slides “imageplaceholder” , have added the base64image data along with this folder.
Kindly let me know for more details
@arun08,
The dimensions of the image (base64 data) and the dimensions of the “imageplaceholder” are different. Could you please specify the expected result?
@andrey.potapov , I apologies for that, The template image would just be a placeholder we can relpace it with any other shape if it works, I can also be a empty shape and want to place the image in that placeholder.
@arun08,
Thank you for the clarification. I am working on the issue and will get back to you soon.
@arun08,
I was unable to replace the image in the picture frame with the image from the base64 string.
We have opened the following new ticket(s) in our internal issue tracking system and will investigate the issue according to the terms mentioned in Free Support Policies.
Issue ID(s): SLIDESNODEJS-64
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.