如何将图像添加到PDF文件中

问题描述 投票:0回答:2

我在线尝试了很多示例代码,但我无法弄清楚如何将图像实现为Itext PDF文件。有人可以帮帮我吗?

谢谢。

android itext
2个回答
0
投票
// This is written based on ItextPdf java 
            Document document = new Document();
            PdfWriter.getInstance(document, new FileOutputStream("sample1.pdf"));
            document.open();
            Image img = Image.getInstance("arvind-rai.png");
            document.add(new Paragraph("Sample 1: This is simple image demo."));
            document.add(img);
            document.close();


// Follow below link if you want solution in android 
https://stackoverflow.com/a/15742238/5380981

0
投票

这是支票的解决方案,

Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream("sample2.pdf"));
        document.open();
        Image img = Image.getInstance("arvind-rai.png");
        img.setAbsolutePosition(450f, 10f);
        document.add(img);
        document.close();
© www.soinside.com 2019 - 2024. All rights reserved.