c# - 使用 iTextsharp 在没有 Acrofields 的情况下编辑 pdf 模板

标签 c# pdf itext

我有一个 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/

相关文章:

c# - 无锁、可等待、独占的访问方式

c# - 如何知道WebBrowser 控件加载完包括flash 在内的所有内容?

pdf - Xamarin Android : How to Share PDF File From Assets Folder? 通过 WhatsApp 我收到消息说您选择的文件不是文档

java - iText连续PDF编辑java

c# - iTextSharp - 非常大的表内存泄漏

c# - 从 app.config 文件的 web.config 部分获取值?

c# - 在 ASP.NET Core 中使用 MimeMapping

node.js - 如何在node/express应用程序中使用prawn pdf

php - 设置 PHP 和 mySQL 脚本以自动化邮政文书工作

java - Itext pdf setKeepTogether 不重复标题行