无法使用PDFBox将TIFF添加到pdf

时间:2015-11-27 14:59:50

标签: java pdf tiff pdfbox

我尝试使用Java和PDFBox 1.8.10将TIFF图像(CCIT Group 3)添加到PDF。输出文件中显示了一个图像,但显示错误。它只有一些黑白像素。

    String outputPath = "/tmp/PDFImage.pdf";
    String imagePath = "/tmp/header.tif";

    PDDocument doc = new PDDocument();
    PDPage page = new PDPage();
    doc.addPage(page);
    PDPageContentStream content = new PDPageContentStream(doc, page);

    PDXObjectImage ximage = new PDCcitt(doc, new RandomAccessFile(new File(imagePath), "r"));

    content.drawImage(ximage, 0, 500);

    content.close();
    doc.save(outputPath);
    doc.close();

PDFBox依赖项说:要编写TIFF图像,将需要JAI ImageIO核心库。 我导入了库并扫描了插件,但是没有找到一个如何使用的例子。有人可以帮忙吗?

0 个答案:

没有答案