首页 > 解决方案 > iTextsharp:减少从 pdf 阅读器提取的文本中字符之间的间距

问题描述

我发现从 pdf 阅读器中提取的文本中出现的字符之间的间距更大。我不想使用提取文本中的功能"trim""replace"

建议我如何避免字符之间的间距

我已经尝试过 ITextExtractionStrategy,但它没有用

我不想修剪或替换提取文本中的注释

StringBuilder pdfContent = new StringBuilder();

for (int i = 1; i <= reader.NumberOfPages; i++)

 {

ITextExtractionStrategy its = new iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy();
                    pdfContent.Append(PdfTextExtractor.GetTextFromPage(reader, i, its));

  }

reader.Close();
                string strPdfContent = Convert.ToString(pdfContent);

=================

提取文本:

检验批号:123456789 材料 0 8 1 6 0 1 1 2 0 0 1 LBLDTUBELIATFLUA / B & RSVIVDB 批号:8 7 6 8 4 ZV 批号批号:过期日期:2 0 2 0 - 0 8 - 3 1 I n 规格类型 : G oods Rceiptfrom Pr oduction

================

预期文本:

Inspection lot: 123456789
Material 07568681001 OBID CAR COBAS LIAT FLU A/B Batch: 87684Z
Vendor Batch: Expiry date: 2020-08-31
Inspection Type: Goods Receipt from Production

标签: c#itext

解决方案


推荐阅读