且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-01-11 12:33:32

没有更多细节,你应该这样做是在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.