Hello,
I am trying to convert PNG’s and TIFF’s to PDFs.
I am running Apose.PDF version 17.2.0 for Java on a Linux machine. Attached is the problematic PNG. I am having the same issue for TIFFs.
The following java code is failing with Document Conversion Error on Linux (Interestingly the code works on a mac):
Document document = new Document();
Page page = document.getPages().add();
Image image = new Image();
BufferedImage bufImage;
try {
bufImage = ImageIO.read(new File(fullFilePath));
} catch (IOException e) {
e.printStackTrace();
return;
}
// Get the width and height of the image
int width = bufImage.getWidth();
int height = bufImage.getHeight();
double ratio = (double) 525 / (double) width;
double effectiveHeight = (double) ratio * (double) height;
int bottomMargin = 842 - (int)effectiveHeight;
image.setFile(fullFilePath);
page.getPageInfo().getMargin().setBottom(bottomMargin);
page.getPageInfo().getMargin().setTop(0);
page.getPageInfo().getMargin().setRight (0);
page.getPageInfo().getMargin().setLeft (0);
page.getParagraphs().add(image);
document.save(fullTargetPath);
For ping.PNG (24.3 KB)