【发布时间】:2014-10-28 23:43:09
【问题描述】:
使用 iTextSharp,我有以下代码,它成功地提取了我正在尝试阅读的大多数 PDF 的 PDF 文本...
PdfReader reader = new PdfReader(fileName);
for (int i = 1; i <= reader.NumberOfPages; i++)
{
text += PdfTextExtractor.GetTextFromPage(reader, i);
}
reader.Close();
但是,我的一些 PDF 具有 XFA 表单(已填写),这会导致“文本”字段被以下垃圾填充...
"Please wait... \n \nIf this message is not eventually replaced by the proper contents of the document, your PDF \nviewer may not be able to display this type of document. \n \nYou can upgrade to the latest version of Adobe Reader for Windows®, Mac, or Linux® by \nvisiting http://www.adobe.com/products/acrobat/readstep2.html. \n \nFor more assistance with Adobe Reader visit http://www.adobe.com/support/products/\nacrreader.html. \n \nWindows is either a registered trademark or a trademark of Microsoft Corporation in the United States and/or other countries. Mac is a trademark \nof Apple Inc., registered in the United States and other countries. Linux is the registered trademark of Linus Torvalds in the U.S. and other \ncountries."
我该如何解决这个问题?我尝试使用 iTextSharp 中的 PdfStamper[1] 来展平 PDF,但这不起作用 - 生成的流具有相同的垃圾文本。
[1]How to flatten already filled out PDF form using iTextSharp
【问题讨论】:
标签: pdf itextsharp