我有一个 pdf 模板没有 AcroFields,我需要替换其中的文本。文本的格式如下 ((aFieldToReplace))
,但也有需要用 n 编号的行填充的表格。
有什么好的教程、资源或示例可以找到吗?
Is there a way to replace a text in a PDF file with itextsharp?或多或少有相同的问题,但答案忽略了问题的“无 Acrofield”部分。
编辑:
为了让它更难,我有多个模板可以使用。模板都有自己的格式样式(字体、颜色...)
编辑 2:
目的是用数据库中的一些数据创建一个报告。数据库中的数据来自 ASP.NET MVC 应用程序中的多种形式。
根据所选模板,报告可以有多种布局。
模板应该可以动态添加,所以我不能从头开始创建布局。我真的需要从模板中获取布局。
最佳答案
引用优秀iText in Action :
In a PDF document, every character or glyph on a PDF page has its fixed position, regardless of the application that’s used to view the document. […] Suppose you want to replace the word “edit” with the word “manipulate” in a sentence, you’d have to reflow the text. You’d have to reposition all the characters that follow that word. Maybe you’d even have to move a portion of the text to the next page. That’s not trivial, if not impossible. […] Don’t expect any tool to be able to edit a PDF file the same way you’d edit a Word document.
PDF 是一种文档显示格式。如果你想要模板化,你可能不得不使用其他东西。
关于c# - 使用 iTextsharp 在没有 Acrofields 的情况下编辑 pdf 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7820133/