Hello,
We are trying to convert docx->pdf, and we are providing an image quality value for compression. The resulting pdf document contains images that are scrambled and unrecognizable.
Product: GroupDocs.Conversion
Versions Tested: 21.10.1, 22.3
OSs Tested: Linux Red Hat 8.3, macOS Catalina
Sample Code:
private static void wordToPdf() throws Exception {
try (InputStream is = WordConvert.class.getClassLoader().getResourceAsStream("sample_image_doc.docx");
FileOutputStream fos = new FileOutputStream("converted_docx.pdf")) {
ConverterSettings converterSettings = new ConverterSettings();
WordProcessingLoadOptions wordDocLoadOptions = new WordProcessingLoadOptions();
Converter pdfConvertor = new Converter(is, wordDocLoadOptions, converterSettings);
//Optimizations
PdfOptions pdfOptions = new PdfOptions();
PdfConvertOptions convertOptions = new PdfConvertOptions();
PdfOptimizationOptions pdfOptimizationOptions = new PdfOptimizationOptions();
pdfOptimizationOptions.setImageQuality(50);
pdfOptimizationOptions.setCompressImages(true);
pdfOptions.setOptimizationOptions(pdfOptimizationOptions);
convertOptions.setPdfOptions(pdfOptions);
pdfConvertor.convert(fos, convertOptions);
}
}
Sample Document:
sample_image_doc.docx (1.8 MB)
Produced Output:
converted_docx.pdf (42.1 KB)