logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Paul Rayman  
#1 Posted : Tuesday, January 5, 2016 3:21:59 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Question:
Hi!
Can anyone tell me how to get coordinates in a pdf document using c# or .Net, suppose if some text is written in the pdf document then how do I get coordinates of that text? It's very urgent.
Thanks.

Answer:
This is easily done using the Pdfium.Net SDK. See the example below

Code:

public void ExtractTextInfo()
{
    //Initialize the SDK library
    //You have to call this function before you can call any PDF processing functions.
    PdfCommon.Initialize();

    //Open and load a PDF document from a file.
    using (var doc = PdfDocument.Load(@"c:\test001.pdf"))
    {
        //Get second page from document
        using (var page = doc.Pages[1])
        {
            //Extract text information structure from the page
            // 10 - Index for the start characters
            // 25 - Number of characters to be extracted
            var textInfo = page.Text.GetTextInfo(10, 25);

            //Gets text from textInfo strtucture
            string text = textInfo.Text;

            //Gets a collection of rectangular areas bounding specified text.
            var rects = textInfo.Rects;
        }
    }

    //Release all resources allocated by the SDK library
    PdfCommon.Release();
}
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.