PPTX to PDF conversion reduces quality of images

The source code you’ve provided generates four output pdf files:

  1. input1-current-png-image.pdf

  2. input1-svg-image.pdf

  3. input2-current-png-image.pdf

  4. input2-svg-image.pdf

2 and 4 have had their svgs replaced programatically. The graphics are correctly rendered as vectors in the output pdf.

1 and 3 were saved as is with no replacement. The graphics are incorrectly rendered as rasters in the output pdf.

So it seems that if we do not programatically replace the vector graphics at the time of pdf generation, these vector graphics will be rasterised in the output. Is this correct?

@kurtosys,

Let me try to rephrase the things. The presentation contains 2 images one PNG and one SVG. The PNG image added to slide, SVG image is not added to slide, just added into the presentation image collection.

The Aspose.Slides performs the same logic as PowerPoint. Therefore, if we have a PNG image, we will get a PNG image in the generated PDF.

From the provided sample code and output it seems that the SVG images that are embedded and not replaced are rendered as raster and not vectors.

When drawing a slide, there is no replacement logic in PowerPoint. If something on the slide needs to be replaced, we must do it using Aspose.Slides or in PowerPoint. What kind of replacement are you talking about?

Since the SVG image is not added to the slide, we cannot draw it and should do the replacement ourselves. As far as how to add SVG to presentation slide using MS PowerPoint, I suggest you may contact their support.

There is replacement in the source code you have provided me:

Screenshot 2020-05-19 at 14.17.38.png (261.1 KB)

But let’s move forward from here. I am creating two new test cases. They have both been created from new blank powerpoint (pptx) files. These have been named input1.pptx and input2.pptx.

I have dragged in one svg image file into each pptx file:

image1.svg has been dragged into input1.pptx
image2.svg has been dragged into input2.pptx

There are no PNG files present whatsoever.

I then generate two output files via aspose slides version 20.4 with setSaveMetafilesAsPng(false) as you have suggested. The output1.pdf and output2.pdf are the output files respectively.

The graphics are being rasterised in the output pdfs. There have been no png images added to the input powerpoint files.

If you insist that the issue is that I am embedding pngs, I will need to speak to someone else on this issue. Preferably a developer. Or possibly arrange a live debug session where I show you my process.

I have attached the new test case files

aspose support 3.zip (687.4 KB)

@kurtosys,

I like to share that I am not sure if you are dragging and dropping an SVG image inside presentation and expecting that it gets added as SVG. You can check on your end using Aspose.Slides by iterating the respective shape if the image that you have dragged and dropped has been added as SVG by PowerPoint or as PNG. We have clearly shared that if the SVG is added in slides it will be rendered as SVG. I hope this will be helpful.

I can confirm that the content-type for the image is image/png when i view it via teh aspose.slides api. However the svg is also attached to the aspose image reference. I think this is a bug in aspose.slides. I have exploded the contents of one of the files below:

$ zipinfo input1.pptx
Archive: input1.pptx
Zip file size: 79543 bytes, number of entries: 39
-rw---- 4.5 fat 3246 b- defS 80-Jan-01 00:00 [Content_Types].xml
-rw---- 4.5 fat 738 b- defS 80-Jan-01 00:00 _rels/.rels
-rw---- 4.5 fat 581 b- defS 80-Jan-01 00:00 ppt/slides/_rels/slide1.xml.rels
-rw---- 4.5 fat 1532 b- defS 80-Jan-01 00:00 ppt/slides/slide1.xml
-rw---- 4.5 fat 976 b- defS 80-Jan-01 00:00 ppt/_rels/presentation.xml.rels
-rw---- 4.5 fat 3237 b- defS 80-Jan-01 00:00 ppt/presentation.xml
-rw---- 4.5 fat 311 b- defS 80-Jan-01 00:00 ppt/slideLayouts/_rels/slideLayout9.xml.rels
-rw---- 4.5 fat 4731 b- defS 80-Jan-01 00:00 ppt/slideLayouts/slideLayout1.xml
-rw---- 4.5 fat 3972 b- defS 80-Jan-01 00:00 ppt/slideLayouts/slideLayout2.xml
-rw---- 4.5 fat 5467 b- defS 80-Jan-01 00:00 ppt/slideLayouts/slideLayout3.xml
-rw---- 4.5 fat 5056 b- defS 80-Jan-01 00:00 ppt/slideLayouts/slideLayout4.xml
-rw---- 4.5 fat 8019 b- defS 80-Jan-01 00:00 ppt/slideLayouts/slideLayout5.xml
-rw---- 4.5 fat 3089 b- defS 80-Jan-01 00:00 ppt/slideLayouts/slideLayout6.xml
-rw---- 4.5 fat 2547 b- defS 80-Jan-01 00:00 ppt/slideLayouts/slideLayout7.xml
-rw---- 4.5 fat 6004 b- defS 80-Jan-01 00:00 ppt/slideLayouts/slideLayout8.xml
-rw---- 4.5 fat 5923 b- defS 80-Jan-01 00:00 ppt/slideLayouts/slideLayout9.xml
-rw---- 4.5 fat 4029 b- defS 80-Jan-01 00:00 ppt/slideLayouts/slideLayout10.xml
-rw---- 4.5 fat 4253 b- defS 80-Jan-01 00:00 ppt/slideLayouts/slideLayout11.xml
-rw---- 4.5 fat 311 b- defS 80-Jan-01 00:00 ppt/slideLayouts/_rels/slideLayout5.xml.rels
-rw---- 4.5 fat 311 b- defS 80-Jan-01 00:00 ppt/slideLayouts/_rels/slideLayout6.xml.rels
-rw---- 4.5 fat 311 b- defS 80-Jan-01 00:00 ppt/slideLayouts/_rels/slideLayout7.xml.rels
-rw---- 4.5 fat 311 b- defS 80-Jan-01 00:00 ppt/slideLayouts/_rels/slideLayout11.xml.rels
-rw---- 4.5 fat 311 b- defS 80-Jan-01 00:00 ppt/slideLayouts/_rels/slideLayout10.xml.rels
-rw---- 4.5 fat 311 b- defS 80-Jan-01 00:00 ppt/slideLayouts/_rels/slideLayout4.xml.rels
-rw---- 4.5 fat 311 b- defS 80-Jan-01 00:00 ppt/slideLayouts/_rels/slideLayout8.xml.rels
-rw---- 4.5 fat 1991 b- defS 80-Jan-01 00:00 ppt/slideMasters/_rels/slideMaster1.xml.rels
-rw---- 4.5 fat 13929 b- defS 80-Jan-01 00:00 ppt/slideMasters/slideMaster1.xml
-rw---- 4.5 fat 311 b- defS 80-Jan-01 00:00 ppt/slideLayouts/_rels/slideLayout1.xml.rels
-rw---- 4.5 fat 311 b- defS 80-Jan-01 00:00 ppt/slideLayouts/_rels/slideLayout2.xml.rels
-rw---- 4.5 fat 311 b- defS 80-Jan-01 00:00 ppt/slideLayouts/_rels/slideLayout3.xml.rels
-rw---- 4.5 fat 6384 b- stor 80-Jan-01 00:00 docProps/thumbnail.jpeg
-rw---- 4.5 fat 26633 b- stor 80-Jan-01 00:00 ppt/media/image1.png
-rw---- 4.5 fat 8399 b- defS 80-Jan-01 00:00 ppt/theme/theme1.xml
-rw---- 4.5 fat 15255 b- stor 80-Jan-01 00:00 ppt/media/image2.svg
-rw---- 4.5 fat 818 b- defS 80-Jan-01 00:00 ppt/presProps.xml
-rw---- 4.5 fat 791 b- defS 80-Jan-01 00:00 ppt/viewProps.xml
-rw---- 4.5 fat 182 b- defS 80-Jan-01 00:00 ppt/tableStyles.xml
-rw---- 4.5 fat 689 b- defS 80-Jan-01 00:00 docProps/core.xml
-rw---- 4.5 fat 1302 b- defS 80-Jan-01 00:00 docProps/app.xml
39 files, 143194 bytes uncompressed, 72263 bytes compressed: 49.5%

Powerpoint embeds both a png and svg version of the image within the powerpoint file (ppt/media/image1.png and ppt/media/image2.svg). I believe aspose slides is targeting the png incorrectly when initialising the presentation.

Pdf exports from powerpoint for the same pptx files outputs the graphics as vectors and not rasters.

Pdf exports from word with aspose.word outputs svgs as vectors not rasters. These svgs were added to the word documents by dragging and dropping too.

Office supports adding svgs the same way as other picture files. Here is their support article. I have rerun the tests while adding the svgs via the insert menu and the results are the same. SVGs are rasterised.

Basically aspose.slides doesn’t currently support svgs when they are added via powerpoint. As I said earlier, I think this a bug. Could you check this with your dev/product team possibly?

@kurtosys,

We are sorry for your inconvenience. Based on the information provided by you and it has been observed that issue is happening owing to PowerPoint 2019 on your end. An issue with ID SLIDESJAVA-38109 has been created as new feature request in our issue tracking system to further investigate this on our end. This thread has been linked with the issue so that you may be notified once the support will be included.

Thank you.

Just a note, the version of powerpoint is PowerPoint for Mac 16.37

Screenshot 2020-05-21 at 10.07.41.png (88.3 KB)

@kurtosys,

Thank you for sharing the information with us, I have associated that in our issue tracking system.

Hello. Any feedback on the state of this issue?

@kurtosys,

The issue has just been added in our issue tracking system and we request for your patience. We will update you as soon as we will provide the feature support in API.

Hello. Is there any additional feedback that can be provided on the progress of this issue?

I regret to share that concerned support for rendering SVG in slide to exported output as SVG rather than PNG. We request for your patience and will share updates with you as soon as issue will be fixed.

The issues you have found earlier (filed as SLIDESJAVA-38109) have been fixed in this update.

Thank you. We will test and provide feedback as soon as possible.

@kurtosys,

Please feel free to share if there is still any issue incurring.

Hello aspose support,

Unfortunately the fix provided in aspsose slides for java 20.7 did not resolve the issue. Our testing at the time incorrectly concluded the bug was resolved. In summary:

I have attached an archive with input.pptx, output.pdf and the svg file that is embedded.

files.zip (1.0 MB)

It appears the fix in 20.7 is actually working when combined with pdfOptions.setSaveMetafilesAsPng(false)

The issue can remain closed. We will revive it if we need additional help.

Thank you

@kurtosys

Thank you for the feedback.