在iText中创建PDF图像

编程入门 行业动态 更新时间:2024-10-26 13:34:05
本文介绍了在iText中创建PDF图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试将我在文件系统上的图像作为pdf添加到我即时创建的pdf中。

I'm trying to add an image that I have on the filesystem as a pdf into a pdf that I'm creating on the fly.

我试图将使用Image类,但它似乎不适用于PDF(仅限JPEG,PNG或GIF)。如何从现有PDF创建元素,以便将其放入新PDF?

I tried to use the Image class, but it seems that it does not work with PDFs (only JPEG, PNG or GIF). How can I create an element from an existing PDF, so that I can place it in my new PDF?

推荐答案

请下载我的书第6章并阅读了所有关于班级 PdfImportedPage 。

Please download chapter 6 of my book and read all about the class PdfImportedPage.

在最基本的示例中,您将创建一个 PdfReader 实例并导入页面进入 PdfWriter 实例,从这一点上你可以直接使用 PdfImportedPage 实例,或者包含在图像对象:

In the most basic example, you'd create a PdfReader instance and import the page into the PdfWriter instance, from which point on you can use the PdfImportedPage instance, either directly, or wrapped inside an Image object:

PdfReader reader = new PdfReader(existingPdf); PdfImportedPage page = writer.getImportedPage(reader, i); Image img = Image.getInstance(page); reader.close();

更多推荐

在iText中创建PDF图像

本文发布于:2023-10-31 01:51:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1544641.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   iText   PDF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!