2009-09-22 88 views
4

我正在使用DirectContent方法在我的PDF上對元素進行絕對定位。 我需要遍歷記錄列表並在我的PDF中爲每個記錄構建一個頁面。itextsharp:添加多個頁面

如何告訴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(); 

回答

9

輕鬆足夠其Document.NewPage()函數。

我在其他網站上看到了一些非常奇怪的「解決方案」,希望這可以幫助別人。