
Acrobat lets you add a header and footer throughout a PDF. Headers and footers can include a date, automatic page numbering, Bates numbers for legal documents, or the title and author. You can add headers and footers to one or more PDFs.You can vary the headers and footers within a PDF. For example, you can add a header that displays the page number on the right side of odd-numbered pages, and another header that displays the page number on the left side of even-numbered pages.
When adding Bates numbering, you can set the number of digits, the starting number, and the prefix or suffix to be appended to each Bates number.You can define and save your headers and footers to reuse them later, or you can simply apply a header and footer and forget it. After applying a header and footer, you can edit, replace, or delete it in the PDF. You can also preview headers and footers before applying them and adjust the header and footer margins so that they don’t overlap other page content. Bates numbering is a method of indexing legal documents for easy identification and retrieval. Each page of each document is assigned a unique Bates number that also indicates its relationship to other Bates-numbered documents. Bates numbers appear as headers or footers on the pages of each PDF in the batch.The Bates identifier is referred to as a number, but it can include an alphanumeric prefix and suffix. The prefix and suffix can make it easier to recognize the central subject matter of the files.
You have two problems:Problem 1:PdfReader can only read real PDF files. Those are files that start with%PDF-1 and end with%%EOF.


In your case, you don't have such a file. You are reading TEMPPDF which is a file with 0 bytes. In iText, you create a PDF file in 5 steps. You only have step 1 (creating the document) and step 2 (creating the writer) of the creating process. You are missing steps 3 (opening the document), 4 (adding content) and 5 (closing the document).You only have a complete PDF document after step 5.
It is normal that you get an InvalidPdfException as you aren't reading a complete PDF.Problem 2:You write: I need PdfStamper in my later part of code to render HTML content.This is wrong. PdfStamper is a class that can be used to stamp new content (a watermark, form field values, a header, a footer) on an existing PDF document. In no way does PdfStamper convert PDF to HTML or render PDF as HTML.