有没有办法用itextsharp替换PDF文件中的文本? [英] Is there a way to replace a text in a PDF file with itextsharp?
问题描述
我正在使用itextsharp生成PDF,但我需要动态更改一些文本。
我知道如果有任何AcroField可以改变,但我的PDF doen有任何一个。它只有一些纯文本,我需要更改其中的一些。
I'm using itextsharp to generate the PDFs, but I need to change some text dynamically. I know that it's possible to change if there's any AcroField, but my PDF doen's have any of it. It just has some pure texts and I need to change some of them.
有谁知道怎么做?
推荐答案
实际上,我有一篇关于如何做的博客文章!但就像IanGilham所说,这取决于你是否能控制原始PDF。基本思路是在页面上设置一个表单,并用您想要的文本替换表单字段。 (您可以为表单设置样式,使其看起来不像表单)
Actually, I have a blog post on how to do it! But like IanGilham said, it depends on whether you have control over the original PDF. The basic idea is you setup a form on the page and replace the form fields with the text you want. (You can style the form so it doesn't look like a form)
如果您无法控制PDF,请告诉我如何操作!
If you don't have control over the PDF, let me know how to do it!
以下是完整帖子的链接:
Here is a link to the full post:
使用模板以编程方式创建带有C#和iTextSharp的PDF
这篇关于有没有办法用itextsharp替换PDF文件中的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!