1

How do I get code in the header and footer of a PDF file using C # 2012 (asp.net) + iTextSharp (v5.4.5.0)?

At the moment I can extratir the pages but I need to separate the headers and footers of your content.

Below is my code to get the page:

PdfReader pdfreader = new PdfReader(nmfile);
ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();           

for (int page = 1; page <= pdfreader.NumberOfPages; page++)
{
    extractText = PdfTextExtractor.GetTextFromPage(pdfreader, page, strategy);
        extractText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(extractText)));

    //...
}

Thanks to all

Andrea
  • 11,801
  • 17
  • 65
  • 72
Marco Araujo
  • 165
  • 1
  • 12
  • 3
    PDFs have no concept of a "header" or a "footer", instead, they just happen to have text that appears at locations you associate with these words. Knowing this, you'll need to define what you consider to be a header and footer and then you can try the links in this post: http://stackoverflow.com/a/7515625/231316 – Chris Haas Feb 25 '14 at 18:44
  • Also, please see this post explaining why you should never use Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(extractText))) http://stackoverflow.com/a/10191879/231316 – Chris Haas Feb 26 '14 at 14:12
  • @Marco Araujo - did you get how to read header and footer of pdf as me too looking for same ? – Manisha Oct 23 '18 at 06:36

0 Answers0