如何使用itextsharp在现有pdf中设置文本字段值

问题描述:

我需要操作已创建的javascripted PDF文件。在打印之前需要设置文本字段值。我找不到一个例子。



我需要读取文件,设置值然后打印。我正在使用C#和itextsharp来做这件事。



感谢您的帮助。



我尝试了什么:



搜索并找不到合适的例子。

I need to manipulate an already created javascripted PDF file. There are text field values that I need to set before printing. I cannot find an example so for.

I need to read the file, set the values then print. I am using C# and itextsharp to do this.

Thank you for your help in this.

What I have tried:

Searching and can't find a working example.

没有更多细节,你应该这样做是在PDF中使用占位符标签,这样你就可以在文本中搜索这些标签。



您添加到PDF的标签将是白色的,以便在打印PDF时看不到。



如果您不能使用标签,那么您需要使用Itextsharps PDF压模功能将图像/文本添加到PDF中,然后使用.SetAbsolutePosition打开,将您要放置的内容定位到文档的正确位置。



这里有一些链接,以更好地指导你。在itextsharp上有很多东西,并且考虑到你描述的问题很少,你正在做的事情是由很多其他人完成的,所以谷歌搜索将返回大量的结果,你需要做什么。



c# - ITextSharp将文本插入到现有的pdf - Stack Overflow [ ^ ]



Google [ ^ ]



iTextSharp &安培;#8212;很少有C#的例子。 |简单的.Net解决方案 [ ^ ]



如果你想给你的问题一个机会,然后带回一些代码样本并清楚地定义你的问题,我肯定你会得到更好的帮助。
Without more details the way you should do this is use placeholder labels in your PDF so that way you can search the text for those labels.

The labels you add to your PDF would be white as to not be seen when the PDF is printed.

If you cannot use labels then you need to use Itextsharps PDF stamper functionality to add image/text to your PDF and then use .SetAbsolutePosition on to position what it is you are trying to place into the correct spot on your document.

Here are some links to better guide you. There are tons of things on itextsharp and given the little amount about your issue that you described, what you are doing has been done by plenty others so a google search will return tons of results for what you need to do.

c# - ITextSharp insert text to an existing pdf - Stack Overflow[^]

Google[^]

iTextSharp — few C# examples. | Simple .Net Solutions[^]

If you would like to give your problem a shot and then come back with some code samples and clearly define your issue, I am sure you will get better assistance.