Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iTextSharp "The document has no pages."

Tags:

c#

itextsharp

I'm using iTextSharp to update A PDF's file properties:

FileStream fs = File.Open(@"C:\Developer\C#Projects\BylawSearch\0001.pdf", FileMode.Open);
Document document = new Document();
PdfWriter writer = PdfWriter.GetInstance(document, fs);
document.Open();
document.AddSubject("Blah");
document.AddTitle("Blah blah");
document.AddKeywords("Blah blah blah");
document.Close();

I'm getting a "The document has no pages." error from iTextSharp. Any help appreciated.

like image 368
witchlightning Avatar asked Oct 09 '13 17:10

witchlightning


1 Answers

You haven't added any information to put on a page ... !!

document.Add(new Paragraph("Hello World!"));

... for example.

Your title etc are part of the document properties (rather than something that's "printed" to the pdf).

Check out this introductory example, that seems to cover what you're after.

like image 84
noelicus Avatar answered Sep 20 '22 07:09

noelicus