iTextSharp error -- "The document has no pages"

B

Bluestrattos

Hello!
I need your help!

I want to add a footer to a pre-existent pdf file, or in a more general way
of speak, i want to add a new line to the first page of a pre-existent pdf
file.


I searched for a lot of 3rd party applications, but the trial versions
always leave a trace like "demo version" or "trial version", and for the
tests i've been doing that doen't work.

So I decided to use iTextSharp and i use the code below:

Code snippet:
/***********************************


Document document = new Document();

PdfWriter.GetInstance(document, new FileStream(@"e:\222.pdf",
FileMode.Append));
document.Open();
HeaderFooter footer = new HeaderFooter(new Phrase("This is page:
"), true);
footer.Border = iTextSharp.text.Rectangle.NO_BORDER;
document.Footer = footer;
document.NewPage();
document.Close();


/***********************************************


The problem's when i run the code above i get an error "The document has no
pages".
I searched all over msdn forums, google searches, blogs, you name it, for an
answer, but unsuccessfully.

Does anyone can help me ?

I already saw the iTextSharp documentation, but that only works when we
create a new pdf file, and i want to use pre-existent.

Thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top