tags:

views:

716

answers:

1

I'm using the DirectContent method of absolutely positioning elements on my PDF. I need to iterate over a list of records and build one page per record in my PDF.

How do I tell itextsharp to insert a new page and "draw" to that page?

        // 72point per inch
        // we want 7x10
        iTextSharp.text.Rectangle pageSize = new iTextSharp.text.Rectangle(504, 720);

        Document doc = new Document(pageSize);
        PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(@"C:\temp\backPages.pdf", FileMode.Create));

        doc.Open();
        PdfContentByte cb = writer.DirectContent;

        // "DRAW" IMAGES AND TEXT 
        ...
        //various .Add's called here
        ...
        // Done with drawing images & text
        doc.Close();
+1  A: 

Easily enough its the Document.NewPage() function.

I saw some really odd "solutions" on other sites, hope this helps someone else.

JohnFly