itextsharp:添加多个页面

Box*_*ery 4 c# pdf itextsharp

我正在使用DirectContent方法在我的PDF上绝对定位元素.我需要迭代一个记录列表,并在我的PDF中为每个记录构建一个页面.

如何告诉itextsharp插入新页面并"绘制"到该页面?

        // 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();
Run Code Online (Sandbox Code Playgroud)

Box*_*ery 10

它足够简单的Document.NewPage()函数.

我在其他网站上看到了一些非常奇怪的"解决方案",希望这有助于其他人.