Page Blacks Out After Compression

@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.

@sergei.shibanov

Can we have an update for this ticket?

@Aswin0892
Unfortunately, there is nothing new on this issue yet. As soon as new information appears, I will write.

The issues you have found earlier (filed as PDFNET-56561) have been fixed in Aspose.PDF for .NET 24.6.

Hi,

We are still facing the blackout issue in the documents while doing compression for couple of times on the same document. Attached the screenshot for your reference.

Blackout_Screenshot.png (51.2 KB)

Note: We have tried our end and can able to simulate this issue from the version 24.3

@Aswin0892
Is this for another document/code?
For the document and code that you provided earlier, was the problem solved?

Hi,

This is happening for the another document for the same code, attached is the overall code which we are using for Grayscale conversion and compression which will be called sequentially.

Grayscale_Compression_Code_Snippet.docx (21.5 KB)

For earlier shared document we are not getting this issue for the same code attached above.

@Aswin0892
Please attach the document with which this situation occurs.

Hi @sergei.shibanov,

Attached is the sample document in which we are getting blackout issue when we are using the Grayscale & Compression code.

ct18665164758-20240707111257824-274-50.pdf (95.6 KB)

@Aswin0892
I tried to reproduce the problem using the following code.

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

        // Convert the RGB colorspace image to GrayScale colorspace
        strategy.Convert(page);
    }

    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;

    doc.OptimizeResources(optimizationOptions);
    doc.Save(dataDir + "black-out.pdf");                
}

In my environment, a valid document is obtained (for the library version 24.06).
black-out.pdf (66.8 KB)
Maybe this code has differences from the one you use.

By the way I wanted to note that when you call Dispose inside using, you end up calling Dispose twice on the same object, and this is incorrect.
1.png (45.3 KB)

@sergei.shibanov,

Try doing the optimization again for the “black-out.pdf” document using the compression code, there only the pages are getting blackout.

Note: This was not happening with version 24.2.0 with the same code.

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

                // Convert the RGB colorspace image to GrayScale colorspace
                strategy.Convert(page);
            }

            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;

            doc.OptimizeResources(optimizationOptions);
            doc.Save(dataDir + "black-out.pdf");


            var optimizationOptions1 = new Aspose.Pdf.Optimization.OptimizationOptions();
            optimizationOptions1.RemoveUnusedObjects = true;
            optimizationOptions1.RemoveUnusedStreams = true;
            optimizationOptions1.AllowReusePageContent = true;
            optimizationOptions1.LinkDuplcateStreams = true;
            optimizationOptions1.UnembedFonts = true;
            optimizationOptions1.ImageCompressionOptions.CompressImages = true;
            optimizationOptions1.ImageCompressionOptions.ImageQuality = 50;
            optimizationOptions1.ImageCompressionOptions.ResizeImages = true;
            optimizationOptions1.ImageCompressionOptions.Version = Aspose.Pdf.Optimization.ImageCompressionVersion.Fast;
            optimizationOptions1.ImageCompressionOptions.MaxResolution = 200;

            doc.OptimizeResources(optimizationOptions1);
            doc.Save(dataDir + "black-out1.pdf");
        }

image.png (33.0 KB)

image.jpg (82.1 KB)

@Aswin0892
Thanks for the tip, when adding another call to
doc.OptimizeResources(optimizationOptions);
the result is really invalid.
(and conversion to gray does not affect the reproduction of the problem).
I’ll create a task for the development team.

1 Like

@Aswin0892
I did it simpler - I called doc.OptimizeResources twice.
But I think the result is the same.

using (var doc = new Aspose.Pdf.Document(dataDir + "ct18665164758-20240707111257824-274-50.pdf"))
{
    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;

    doc.OptimizeResources(optimizationOptions);
    doc.OptimizeResources(optimizationOptions); // call twice
    doc.Save(dataDir + "black-out.pdf");                
}

black-out.pdf (64.5 KB)

1 Like

@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-57627

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.

The issues you have found earlier (filed as PDFNET-57627) have been fixed in Aspose.PDF for .NET 24.9.