Page Blacks Out After Compression

Hi,

PFA, Particular pages are getting blacks out after the compression code which is mentioned below. Currently, we are using the version v23.9.0.

                    using (Aspose.Pdf.Document docs = new Aspose.Pdf.Document(item1.FullName))
                    {
                        var optimizationOptions = new Aspose.Pdf.Optimization.OptimizationOptions();
                        optimizationOptions.RemoveUnusedObjects = true;
                        optimizationOptions.RemoveUnusedStreams = true;
                        optimizationOptions.AllowReusePageContent = true;
                        optimizationOptions.LinkDuplcateStreams = true;
                        optimizationOptions.UnembedFonts = true;
                        optimizationOptions.ImageCompressionOptions.CompressImages = true;
                        optimizationOptions.ImageCompressionOptions.ImageQuality = 50;
                        optimizationOptions.ImageCompressionOptions.ResizeImages = true;
                        optimizationOptions.ImageCompressionOptions.Version = Aspose.Pdf.Optimization.ImageCompressionVersion.Fast;
                        optimizationOptions.ImageCompressionOptions.MaxResolution = 200;

                        docs.OptimizeResources(optimizationOptions);
                        docs.Save(ConvertedImagePath1);
                        docs.Dispose();
                    }

Aspose_Compression_Issue.png (31.3 KB)
11249-01_RecordSummary_Amica_20231031120024.zip (9.8 MB)

@Aswin0892
Please attach a document when working with which this happens.

Attached sample document for your reference.

@Aswin0892
I checked the code provided with the document you attached using version 24.01 of the library and this problem did not reproduce for me. Please try it for yourself with the library version 24.01
Optimized.pdf (3.2 MB)

Hi,

We have tried updating the library to the latest version 24.0.1, but still pages (refer from page no. 8) are getting black out after the Grayscale conversion. Attached the URL for the test file and the code which we have used for Grayscale conversion.

                using (Aspose.Pdf.Document document = new Aspose.Pdf.Document(SourceFilePath + Filename))
                {
                    Aspose.Pdf.RgbToDeviceGrayConversionStrategy strategy = new Aspose.Pdf.RgbToDeviceGrayConversionStrategy();
                    for (int idxPage = 1; idxPage <= document.Pages.Count; idxPage++)
                    {

                        // Get instance of particular page inside PDF
                        Page page = document.Pages[idxPage];
                        // Convert the RGB colorspace image to GrayScale colorspace
                        //strategy.Convert(page);
                        try
                        {
                            //if (page.ColorType == ColorType.Grayscale || page.ColorType == ColorType.Rgb || page.ColorType == ColorType.BlackAndWhite)
                            //{
                            // Convert the RGB colorspace image to GrayScale colorspace
                            strategy.Convert(page);
                            //}

                        }
                        catch (Exception ex)
                        {
                            WriteErrorLog("ConverttoGrayscalePDF Exception - " + " - " + ex);
                            continue;
                        }

                        //page.Dispose();
                    }
                    // Save resultant file
                    document.Save(convertfilename);
                    document.Dispose();
                }

@Aswin0892
Do I understand correctly that this is a different code and source document (not the ones attached in the first message)?

Hi @sergei.shibanov ,

Yes, this is different document and code ( first message is for Compression & last one is for Grayscale Conversion). We are able to replicate the blackout in both the codes with different documents.

Please try to replicate the issue with the latest code and document from your end.

@Aswin0892
When I used the given code and library version 24.02, processing passed without exception.

using (var document = new Aspose.Pdf.Document(dataDir + "Image_9.pdf"))
{
    var strategy = new Aspose.Pdf.RgbToDeviceGrayConversionStrategy();
    for (int idxPage = 1; idxPage <= document.Pages.Count; idxPage++)
    {
        // Get instance of particular page inside PDF
        Page page = document.Pages[idxPage];

        strategy.Convert(page);
    }
    // Save resultant file
    document.Save(dataDir + "Image_9-out.pdf");
    document.Dispose();
}

@sergei.shibanov

Can u please share the output file to verify from our end.

@Aswin0892
Do you have a license?
It shows to me that it is not.

@sergei.shibanov

Yes, we have license with our organization account.

@Aswin0892

I added watermarks to the resulting document.
With a license using the latest version of the library 24.02, you can create a document without watermarks.

Aspose_Sample_Doc.png (172.8 KB)

@sergei.shibanov,

Please refer from page 8 - 16 & pages after 22, some black out is happening to the pages. Attached the screenshot for reference.

@Aswin0892
I’m sorry, I looked and no exception was raised. Although, as you indicated, the problem is in pages starting from the eighth.
I’ll create a task for the development team to look into and fix this.

@Aswin0892
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-56561

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.