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