Hi,
When compressing the file Concertae.pdf (1.2 MB) using a code such as this
OptimizationOptions options = new();
options.ImageCompressionOptions.CompressImages = true;
options.ImageCompressionOptions.ResizeImages = false;
options.ImageCompressionOptions.ImageQuality = 40;
using var doc = new Document(memoryStreamContent, true);
doc.OptimizeResources(options);
doc.OptimizeSize = true;
doc.Optimize();
(Aspose.PDF 25.4.0)
the resulting file Compressed.pdf (455.2 KB) cannot be opened by Adobe Acrobat Reader or Pro, which show the error message “Insufficient data for an image.”.
Could you please tell us what specific attribute of the offending bitmap causes this problem so that we can disable image compression to avoid this issue?
@Olivier.G
Thank you for writing to us - I reproduced the problem and will create a task for the development team to fix it.
In my environment, the problem went away when disabling the line
doc.OptimizeResources(options);
i.e. with the code
OptimizationOptions options = new();
options.ImageCompressionOptions.CompressImages = true;
options.ImageCompressionOptions.ResizeImages = false;
options.ImageCompressionOptions.ImageQuality = 40;
using var doc = new Document(dataDir + "Concertae.pdf", true);
//doc.OptimizeResources(options); <---- this disabled.
doc.OptimizeSize = true;
doc.Optimize();
doc.Save(dataDir + "Concertae_out.pdf");
(however, I determined this simply by trying and I cannot give technical explanations of how this spoils the result).
@Olivier.G
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-59852
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.
@sergei.shibanov thank you for your quick reply.
Until the issue is fixed, could you identify what causes the problem in the first place so that we can disable optimisation only when necessary? Even detecting the issue post optimisation would enable us to implement a fallback strategy…
This is a wild guess but could it have something to do with “Adobe APP14 marker segment”?
The uncompressed stream which causes the issue is
<</BitsPerComponent 8/ColorSpace/DeviceRGB/Filter/DCTDecode/Height 292/Length 2082/Name/X/Subtype/Image/Type/XObject/Width 726>>stream
ÿØÿî Adobe d ÿÛ Å ee'e$''''$25552;;;;;;;;;; e %%#(((((#,0000,7;;;7;;;;;;;;;; e %%#(((((#,0000,7;;;7;;;;;;;;;;ÿÝ .ÿÀ $Ö " ÿÄ¢ a
a
^C a
!"#$%&'()*123456789:ABCDEFGHIJQRSTUVWXYZabcdefghijqrstuvwxyz‚ƒ„…†‡ˆ‰Š‘’“”•–—˜™š¡¢£¤¥¦§¨©ª±²³´µ¶·¸¹ºÁÂÃÄÅÆÇÈÉÊÑÒÓÔÕÖרÙÚáâãäåæçèéêðñòóôõö÷øùú ^C a
!"#$%&'()*123456789:ABCDEFGHIJQRSTUVWXYZabcdefghijqrstuvwxyz‚ƒ„…†‡ˆ‰Š‘’“”•–—˜™š¡¢£¤¥¦§¨©ª±²³´µ¶·¸¹ºÁÂÃÄÅÆÇÈÉÊÑÒÓÔÕÖרÙÚáâãäåæçèéêðñòóôõö÷øùúÿÚ ? œBž aÿМBž aÿÑœBž aÿÒœBž aÿÓœBž aÿÔœBž aÿÕœBž aÿÖœBž aÿלBž aÿМBž aÿÑœBž aÿÒœBž aÿÓœBž aÿÔœBž aÿÕœBž aÿÖœBž aÿלBž aÿМBž aÿÑœBž aÿÙ
endstream
when compressed, it becomes
<</BitsPerComponent 1/ColorSpace 32 0 R/Filter/FlateDecode/Height 292/Length 130/Name/Im2/Subtype/Image/Type/XObject/Width 726>>stream
xœíÒ¡ À0þ¿™,
‡`i_ØÆà4ׇ¦†Ü¸šWÓãjz\M«éq5=®¦ÇÕô¸šWÓãjz\M«éq5=®¦ÇÕô¸šWÓãjz\M«éq5=®¦ÇÕô¸šWÓãjz\M«éq5=®¦ÇÕô¸šWÓãjz^½ojÙª
endstream
@Olivier.G
This is definitely related to the images - because if I remove them all from the document, the resulting document is valid.
In one of the options, I removed (in Acrobat Pro) two images that extend beyond the page and one corresponding to the blue rectangle in the center.
edited_Concertae.pdf (1.2 MB)
For this document, after optimization, the result opens in Acrobat, but when scrolling, it again gives an error (obviously related to the blue rectangles at the bottom of the page).
A quick look at the document shows something complex for ColorSpace,
ColorSpace.png (2.2 KB)
but it is impossible to say whether this is the cause.
What can be said with certainty is that the image with the Concertae text is not the cause.
Do you have a timeframe as to when you’re planning to look at this issue?
In the mean time, could you provide us with a method to identify documents for which image compression produces invalid PDFs, so that we can use a workaround?
@Olivier.G
Nothing new for this task yet. Created tasks are solved in the order they are received, taking into account priorities.
The highest priority is for tasks with paid support, followed by tasks from users who have purchased a license.
The time it takes to solve problems can also vary. Therefore, unfortunately, it is not even possible to give ETA.