Grayscaling PDFs causes textboxes to get blacked-out

Aspose_Grayscale_Example_Textbox_Problem.PNG (85.0 KB)
Aspose_Grayscale_Example_Textbox_Problem_SampleMessageWithTextBox.pdf (50.8 KB)
Aspose Team,

We’re trying to convert a color PDF to its grayscale equivalent using what appears to be the
recommended solution (cited several places, one link provided) using the Aspose Java APIs:
(https://blog.aspose.com/pdf/change-pdf-colorspace-from-rgb-to-grayscale-access-xml-elements-during-conversion-and-support-of-alpha-channel-to-create-transparent-text-and-drawing-objects/).

Sample code excerpt:

Document document = new Document(“input.pdf”);
com.aspose.pdf.RgbToDeviceGrayConversionStrategy strategy = newcom.aspose.pdf.RgbToDeviceGrayConversionStrategy();
for (int idxPage = 1; idxPage <= document.getPages().size(); idxPage++)
{
Page page = document.getPages().get_Item(idxPage);
strategy.convert(page);
}
document.save(“output_grayscale.pdf”);

However, when using the suggested APIs and providing the attached PDF as the “input.pdf”, we
see an issue where the text embedded in the shaded text box gets “blacked-out” (like a redaction) after
attempting to convert the input pdf to grayscale (see attached PNG image). Actually, after the above code is run, the output grayscale PDF is no longer recognized as a PDF that’s viewable with the Adobe Acrobat PDF viewer. In order to see the results of the above PDF conversion, we then attempt to convert the grayscaled PDF into a TIFF image in order to view the output. That sample code looks something like this:

Document pdfDocument = new Document(inputFilePath);
imageStream = new FileOutputStream(outputFilePath);
Resolution resolution = new Resolution(300);
TiffSettings tiffSettings = new TiffSettings();
tiffSettings.setCompression(CompressionType.LZW); // same result if this is CompressionType.CCITT4
tiffSettings.setDepth(ColorDepth.Default); // same result if this is ColorDepth.Format8bpp
tiffSettings.setSkipBlankPages(false);
TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);
tiffDevice.process((IDocument) pdfDocument, imageStream);

Please advise on whether there is some type of adjustment that can be made to improve the grayscale rendering we’re getting from Aspose so that the embedded message textbox doesn’t get blacked-out. Also, is there a reason the grayscale PDF result file is not an acceptable PDF format for the Adobe viewer?

Thank you for your help.

Jerry

One note: these tests were run using Aspose-PDF version 19.5. Thanks.

@jmuth

Thank you for contacting support.

We have been able to notice the problem while converting to greyscale. We have also tried below approach but requirements are not achieved. Therefore, a ticket with ID PDFJAVA-38827 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

Document doc = new Document(dataDir + "Aspose_Grayscale_Example_Textbox_Problem_SampleMessageWithTextBox.pdf");
for (int idxPage = 1; idxPage <= doc.getPages().size(); idxPage++)
{
Page page = doc.getPages().get_Item(idxPage);
page.makeGrayscale();
}
doc.save(dataDir + "Gray_output.pdf");

We are sorry for the inconvenience.

Farhan,

Thank you for the prompt update and for filing a ticket on our behalf. We appreciate the help and look forward to a resolution.

Jerry

@jmuth

We will let you know once any update will be available in this regard.

Is there any update on this?

@aweech

Thank you for contacting support.

This ticket is scheduled for investigations at the start of December 2019. We will let you know once any update will be available.

Hello @Farhan.Raza was this ticket investigated? Thanks.

@aweech,

We are working on this and will share good news with you soon. I request for your patience.

@Adnan.Ahmad - Any more news on this issue? We’re awaiting a solution. Thanks.

@jmuth,

I have observed your comments. I regret to inform that issue is still unresolved owing to missing support in Aspose.PDF. The issue is blocked owing to missing implementation in Aspose.PDF for .NET. This issue will be resolved first in .NET than in Aspose.PDF Java. We will share good news with you regarding ETA for this issue soon.

The issues you have found earlier (filed as PDFJAVA-38827) have been fixed in Aspose.PDF for Java 21.8.