Hi Aspose Team, when I use the aspose pdf to convert pdf format file to tiff format file. If the compress type is CCITT4 or CCITT3. The definition of generated file is very low.
Here is the pdf file.
meeting test2.pdf (272.8 KB)
Here is the generated file.
meeting test.tiff.zip (30.4 KB)
You can see that the text on the calendar is not clear.
My aspose pdf version is 23.6. My platform is Macos 13.4.1. (I have test it on centos, the result is the same)
My test code is here.
private static void exeConvert(String sourceFile, String targetFile) throws Exception {
// Open document
Document pdfDocument = new Document(sourceFile);
// Create stream object to save the output image
java.io.OutputStream imageStream = new java.io.FileOutputStream(targetFile);
// Create Resolution object
Resolution resolution = new Resolution(200,200);
// instantiate TiffSettings object
TiffSettings tiffSettings = new TiffSettings();
// set the compression of resultant TIFF image
tiffSettings.setCompression(CompressionType.CCITT4);
// set the color depth for resultant image
tiffSettings.setDepth(ColorDepth.Format8bpp);
// skip blank pages while rendering PDF to TIFF
tiffSettings.setSkipBlankPages(true);
// for test
// tiffSettings.setUseAlternativeImageEngine(true);
// Create TiffDevice object with particular resolution
double width = pdfDocument.getPages().get_Item(1).getRect().getWidth();
double height = pdfDocument.getPages().get_Item(1).getRect().getHeight();
TiffDevice tiffDevice = new TiffDevice(1728, (int) (height / width * 1728), resolution, tiffSettings);
// Convert a all pages of PDF file to TIFF format
tiffDevice.process(pdfDocument, imageStream);
// Close the stream
imageStream.close();
}
public static void main(String[] args) throws Exception {
String targetFile = "test.tiff";
File file = new File(targetFile);
file.getParentFile().mkdirs();
exeConvert("test2.pdf", targetFile);
}
For some reason, we have to use the compress type CCITT4 or CCITT3. Is there a way to improve the quality of generated tiff file?