[英]Merging documents with itextsharp
I am not experienced with iTextSharp
and have this need: 我没有
iTextSharp
经验,并且有以下需求:
I have generated 2 PDFs: 我生成了2个PDF:
a small PDF (ie size A6) of one page containing 1 background image and some text in various format (paragraph, chunks, etc), some barcode some rectancles... But nothing more (no forms etc). 一页的小PDF(即A6大小),包含1个背景图像和一些各种格式的文本(段落,大块等),一些条形码,一些矩形……但是仅此而已(没有表格等)。 The pdf is generated to a memory stream.
pdf生成到内存流。
a bigger one (ie size A3). 更大的一个(即A3尺寸)。 I want to "copy" or embed the little pdf to the bigger in a fixed position.
我想“复制”或将小pdf嵌入到固定位置。
How can I merge them? 如何合并它们? All examples I found use
PDFReader
, but I am not able to use it on a memory stream and I dont' like to save intermediate PDF to disk. 我发现的所有示例都使用
PDFReader
,但是我无法在内存流上使用它,并且我不喜欢将中间PDF保存到磁盘。
You essentially want to stamp a page from one document somewhere onto the bigger page of another one. 本质上,您希望将一个文档中的某个页面标记到另一个文档的较大页面上。
This is a task for a PdfStamper
. 这是
PdfStamper
的任务。
PdfReader readerA
PdfReader readerA
打开带有小页面的文档 PdfReader readerB
PdfReader readerB
打开带有大页面的文档 PdfStamper stamperB
for readerB
PdfStamper stamperB
创建一个PdfStamper stamperB
readerB
readerA
using stamperB.GetImportedPage
stamperB.GetImportedPage
从readerA
导入页面 stamperB.OverContent.AddTemplate
; stamperB.OverContent.AddTemplate
将导入的页面对象添加到现有目标页面; this method allows to supply positioning coordinates stamperB
, then the readers stamperB
,然后读者
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.