I’m using the following code to convert a TIF to a PDF:
public File convertToPDF(File img) throws IOException {
var pdfFileName = FilenameUtils.getBaseName(img.getName()) + "." + PDF;
try (var document = new Document()) {
var read = ImageIO.read(img);
var page = document.getPages().add();
page.getPageInfo().setHeight(read.getHeight());
page.getPageInfo().setWidth(read.getWidth());
page.getPageInfo().getMargin().setBottom(0);
page.getPageInfo().getMargin().setTop(0);
page.getPageInfo().getMargin().setRight(0);
page.getPageInfo().getMargin().setLeft(0);
var image = new Image();
image.setImageStream(new FileInputStream(img));
page.getParagraphs().add(image);
document.save(pdfFileName);
}
Files.delete(img.toPath());
return new File(pdfFileName);
}
It’s working well with a single page TIF, but when I want to convert a two page TIF the results is a white PDF…
Why ?