![](/img/trans.png)
[英]how to insert image into all pages of a pdf for a c# console application
[英]How to insert an image into a pdf document with C#?
我正在寻找一种使用免费 dll 库修改 pdf 的方法。 我想将图像插入到 pdf 文档的某个位置。
我已经找到了 iTextSharp,但这只会在我的文档之前添加一个页面。
如何将图像插入到特定位置?
var reader = new PdfReader(inputPdfStream);
var stamper = new PdfStamper(reader, outputPdfStream);
var pdfContentByte = stamper.GetOverContent(1);
iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(inputImageStream);
iTextSharp.text.Rectangle r_01 = new iTextSharp.text.Rectangle(30,10);
PdfContentByte page1 = stamper.GetOverContent(1);
image.SetAbsolutePosition(0,0);
page1.AddImage(image);
stamper.Close();
ITextSharp 是一个不错的选择,您实际上可以将图像添加到现有页面。 我们使用它来自动生成我们的产品模板并添加二维码。
请在此处查看 Darin Dimitrov 的回答: 如何在现有 PDF 中使用 iTextSharp 插入图像?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.