繁体   English   中英

itextsharp:添加多个页面

[英]itextsharp : Adding multiple pages

我正在使用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();

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM