We have subscribed Aspose.PDF for Java iand using version 22.3 to convert PDF document to grayscale with the RgbToDeviceGrayConversionStrategy.
As refer to online documents: https://docs.aspose.com/pdf/java/optimize-pdf/
Sample Code:
try (InputStream is = new FileInputStream("/temp/A6_uk_portrait.pdf");
OutputStream os = new FileOutputStream("/temp/A6_uk_portrait_gray.pdf");
Document pdfDocument = new Document(is)) {
RgbToDeviceGrayConversionStrategy strategy = new RgbToDeviceGrayConversionStrategy();
PageCollection pageCollection = pdfDocument.getPages();
for (int pageNum = 1; pageNum <= pageCollection.size(); pageNum++) {
Page page = pageCollection.get_Item(pageNum);
strategy.convert(page);
}
pdfDocument.save(os);
}
Most of our PDF documents work fine but the attached PDF documents (A6_uk_portrait.pdf) is not working.
As attached the grayscale output from Aspose.PDF for Java (A6_uk_portrait_gray.pdf), the texts are converted to grayscale but the lines and the alert icon are still in color.
Is there any solution of Aspose.PDF for Java can resolve this issue.
A6_uk_portrait.pdf (22.5 KB)
A6_uk_portrait_gray.pdf (23.1 KB)