How to find x,y location of a text in pdf

a 夏天 提交于 2019-12-05 00:05:30

问题


Is there any tool to find the X-Y location on a text content in a pdf file ?


回答1:


Docotic.Pdf Library can do it. See C# sample below:

using (PdfDocument doc = new PdfDocument("your_pdf.pdf", "password_if_need"))
{
    foreach (PdfTextData textData in doc.Pages[0].Canvas.GetTextData())
        Console.WriteLine(textData.Position + " " + textData.Text);
}



回答2:


Try running "Preflight..." in Acrobat and choosing PDF Analysis -> List page objects, grouped by type of object.

If you locate the text objects within the results list, you will notice there is a position value (in points) within the Text Properties -> * Font section.




回答3:


TET, the Text Extraction Toolkit from the pdflib family of products can do that. TET has a commandline interface, and it's the most powerful of all text extraction tools I'm aware of. (It can even handle ligatures...)

Geometry
TET provides precise metrics for the text, such as the position on the page, glyph widths, and text direction. Specific areas on the page can be excluded or included in the text extraction, e.g. to ignore headers and footers or margins.



来源:https://stackoverflow.com/questions/4740157/how-to-find-x-y-location-of-a-text-in-pdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!