Free Support Forum - aspose.com

Convert PDF to Greyscale using Java with Aspose.PDF - Output is corrupted

We recently ran into an issue trying to convert a color pdf file to greyscale. The resulting file when opened in adobe is corrupted, but what is shown still has some resulting color in it.

String fileName = "APCO+Flyer+2018.pdf";
String finalPdfName = fileName.replace(".pdf", "_grey.pdf");
RgbToDeviceGrayConversionStrategy strategy = new RgbToDeviceGrayConversionStrategy();
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(fileName);
for (int idxPage = 1; idxPage <= pdfDocument.getPages().size(); idxPage++) {
	Page page = pdfDocument.getPages().get_Item(idxPage);
	strategy.convert(page);
}
pdfDocument.save(finalPdfName);

APCO Flyer 2018.zip (105.5 KB)

@mstandfuss

Would you kindly also share the generated output PDF from your side. We will further proceed to assist you accordingly.

@asad.ali the sample should be in the attached zip.

@aweech

We requested for an output PDF which was generated in your requirement so that we can compare it one generated by us.

@asad.ali Are you telling me that the sample is not in the attached zip? I am unable to download the file and view it myself.

@aweech

We have been able to reproduce the issue with your shared PDF document and Aspose.PDF for Java 20.1. We had asked for a resultant PDF document just to compare with the results on our side. Nevertheless, an issue has been logged in our issue tracking system as PDFJAVA-39177. We will further look into details of it and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.