PDF Size 2x Larger than PDF Created From Word


#1

Hello,

I am testing Aspose.Words version 17.9 (eval version with a temporary license).

When I convert a Word document with embedded JPG images to a PDF, I have the following two issues:

  • the resulting PDF is 2x larger that the PDF created by exporting from Word
  • the images in the PDF are very jaggy when viewing in Adobe and zooming in (1200% zoom)

To try and reduce the file size I tried adjusting the downsampling:

//pdfSaveOptions.DownsampleOptions.DownsampleImages = true; // default true
//pdfSaveOptions.DownsampleOptions.ResolutionThreshold = 100; // default 0
//pdfSaveOptions.DownsampleOptions.Resolution = 96; // default 220

I also tried the following, which reduced the size but at the possible expense of image quality. I know it is always a balance between size and quality.

// Defaults to Auto
//pdfSaveOptions.ImageCompression = Aspose.Words.Saving.PdfImageCompression.Jpeg;
//pdfSaveOptions.JpegQuality = 50;

To try and improve the image quality I tried changing the antialiasing and the high quality rendering options:

// Defaults to False
pdfSaveOptions.UseAntiAliasing = true;
pdfSaveOptions.UseHighQualityRendering = true;

I have attached a screenshot of the difference in image quality between the PDF file produced by Aspose and that produced by Word, as well as a zipped sample Word document.

WordToPDFImageJaggy.jpg (180.7 KB)

For my test Word document. I just copied a selection of JPG files from Windows desktop background images to create my file. When converted with Word it gave 2,741KB file while Aspose created a 6,677KB file. I can’t attach the file but if you need it I can get it to you.

Is there anything I can do to get a file size and output quality similar to Word’s PDF export?? :

Thanks,

Sheri


#2

@sheri_steeves,

Thanks for your inquiry. Please ZIP and attach your input Word document here for testing. We will investigate the issue on our side and provide you more information.


#3

Tahir,

I cannot upload the zip itself, it is too large.

Here is a link to a zip containing a smaller sample docx as well as the PDF created from Word’s Export and one through ASPOSE.

http://www.peernet.com/Test/ASPOSE/WordSizeTestwithImages.zip

The PDF created in Word (ExportedFromWord-Standard.pdf) is 948KB while the one from ASPOSE (000_Word Size Test with Images.pdf) is 2,015KB.

As well, there is image quality issue when zooming into the pictures.

Thanks,

Sheri


#4

@sheri_steeves,

Thanks for sharing the documents. We have tested the scenario using latest version of Aspose.Words for .NET 18.1 with following code example and have not found the shared issue. Please use Aspose.Words for .NET 18.1. We have attached the output PDF with this post for your kind reference. 18.1.pdf (540.2 KB)

Document doc = new Document(MyDir + "Word Size Test with Images.docx");
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.DownsampleOptions.ResolutionThreshold = 100;

pdfSaveOptions.ImageCompression = Aspose.Words.Saving.PdfImageCompression.Jpeg;
pdfSaveOptions.JpegQuality = 50;

doc.Save(MyDir + "18.1.pdf", pdfSaveOptions);

#5

Tahir,

Thanks for the file; I can get the same size match in 17.9 by dropping the JPEG compression quality to 50 as you showed above.

This still leaves my other question about the resulting quality of the image in the actual PDF file. The 18.1.pdf that you sent still have the smae jaggedness to the zoomed in image as mine from 17.9. The PDF from word has a much smoother appearance. See the sample screenshot in my first message for an example.

Sheri


#6

@sheri_steeves,

Thanks for your inquiry. Could you please share the zoomed in value at which you are checking the output? Please also share the PDF viewer (e.g Adobe Acrobat) that you are using. We will investigate the issue and provide you more information on this.


#7

Tahir,

I am opening the PDF file in Adobe Reader DC version 2018.009.20050 and zooming into 1200% but the jagged appearance is visible before.

See attached image of PDF from Aspose and PDF from Word shown at 800% zoom in Adobe:

WordToPDFImageJaggy800Zoom.png (82.2 KB)

And this image shown at 800% zoom in Foxit:
Foxit-WordToPDFImageJaggy800Zoom.jpg (108.4 KB)

In both images, the PDF created by Aspose is one the left, and the one from Word is on the right.

Thanks,

Sheri


#8

@sheri_steeves,

Thanks for sharing the detail. We have logged this problem in our issue tracking system as WORDSNET-16330. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.


#9

@sheri_steeves,

Thanks for your patience. It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-16330) as ‘Not a Bug’.

The quiality of images in Pdf output produced by Aspose.Words is not worse that one produced by MS Word. In MS Word there are only two possible options to select final document size. However, Aspose.Words allows more of this. You can control size in pixels and quality of the images.

You can see that size of output documents produced by Aspose.Words and MS Word is almost the same when JpegQuality is set to 80. There is no way to control quality of the output image since we use GDI+ to create images.


#10

Tahir,

Sorry for not getting back to you sooner I was working on other things.

I respectfully with your statement:

The quiality of images in Pdf output produced by Aspose.Words is not worse that one produced by MS Word.

In the images I provided you can see a distinct difference in the image that is placed in the PDF file from Aspose versus the one from the PDF created using Word’s Export PDF. In the one from Word the black lines on the house are smoother and less jagged. There is definitely a more pronounced JPEG compression ringing effect in your PDF.

I agree that in Word you only have two possible options to affect the final document size, and that Aspose’s options give you more control. I have resolved my size issue using the JPEG quality setting you have provided. However, changing the JPEG quality even to 100 does not change the jagged appearance of the image in the final document.

From your last statement:

There is no way to control quality of the output image since we use GDI+ to create images.

I take it there is no way to control this appearance. Are there any plans to improve this?

Sheri


#11

@sheri_steeves,

Thanks for your inquiry. We use GDI+ to create images. Unfortunately, there’s no way to control quality of the output image. However, we have asked for improvement from our product team. As soon as any information is shared by them, we will be more than happy to share that with you.


#12

@sheri_steeves,

Thanks for your patience.

The image format of image in source document is Jpeg. For such cases when JpegQuality is set to 100, original image bytes are written to output document with no modifications. The quality of a image can’t be better that the original. So, we have closed this issue (WORDSNET-16330) as ‘Not a Bug’.