Jojo
Jojo

Reputation: 643

Get PDF Page Number using iTextSharp

I've been playing with this library with no luck. I want to extract the literal 1196 page below. How can I do it with this library?

PageNum

Upvotes: 3

Views: 1862

Answers (1)

Jojo
Jojo

Reputation: 643

OK, after a few tries, I did manage to get that literal page so I am going to share this. So technically, that literal 1196 is a page label and here's the code to get all those labels:

    PdfReader r = new PdfReader(fileName);
     try
     {
        foreach (string s in PdfPageLabels.GetPageLabels(r))
           Console.WriteLine(s);
     }
     catch (Exception ex)
     {
        Console.WriteLine("Error: " + ex.Message);
     }
     finally
     {
        r.Close();
     }

Upvotes: 3

Related Questions