我找到这个其将一个PDF文档到TextChunks拆分TextChunk成单词
是否有任一
a)至每个TextChunk从每个TextChunk进一步分成字/字符和仍然是一个方法能找到它的位置?
或
B)得到解析PDF成字/字符,而不是块,并找到位置的方法?
我找到这个其将一个PDF文档到TextChunks拆分TextChunk成单词
是否有任一
a)至每个TextChunk从每个TextChunk进一步分成字/字符和仍然是一个方法能找到它的位置?
或
B)得到解析PDF成字/字符,而不是块,并找到位置的方法?
是否有方法将每个TextChunk进一步分割为每个TextChunk中的单词/字符并仍然能够找到它的位置?
因为这TextChunk
类只是一个辅助类运输的信息,一个非常小的量,参见不能进一步拆分这些TextChunk
对象它的构造函数参数String str, Vector startLocation, Vector endLocation, float charSpaceWidth,
尤其没有关于单个字符宽度或关联文本大小和字体的信息以从中导出单个字符宽度。
但是你当然可以改变方法RenderText
(其中传入更完整TextRenderInfo
实例被还原成TextChunk
实例):
public virtual void RenderText(TextRenderInfo renderInfo) {
LineSegment segment = renderInfo.GetBaseline();
TextChunk location = new TextChunk(renderInfo.GetText(), segment.GetStartPoint(), segment.GetEndPoint(), renderInfo.GetSingleSpaceWidth());
locationalResult.Add(location);
}
特别地可以先使用其GetCharacterRenderInfos()
分裂TextRenderInfo
实例方法转换为单个字符TextRenderInfo
实例,循环遍历这些实例并为其中的每个实例创建单独的TextChunk
实例。
由于iTextSharp已经切换到新的SourceForge版本控制基础结构,因此您可能不会在存储库中看到该方法。因此,您应该切换到the current iTextSharp repository。
是否有一种方法可以将PDF解析为单词/字符而不是块并找到位置?
当然,你可以实现IRenderListener
创建抽取策略,不正是你需要的。您可以在iText和iTextSharp的stackoverflow上找到关于该主题的一些讨论,例如ITextSharp Find coordinates of specific text in PDF,Get the exact Stringposition in PDF,Retrieve the respective coordinates of all words on the page with itextsharp等。
非常有用的信息,我认为我有它的工作,我很高兴。非常感谢! – user3357963 2013-02-27 16:48:29