We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.PDF for Java convert PDF to grayscale issue

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);

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)


We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as PDFJAVA-41462. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.