c# - itextsharp : Adding multiple pages

标签 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();

最佳答案

Document.NewPage() 函数很简单。

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

关于c# - itextsharp : Adding multiple pages,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1460165/

相关文章:

c# - MultiBinding 转换器未绑定(bind)到 DataTemplate 中的 TextBlock

javascript - jsPDF - 包含其他 pdf

c# - 将 XML 转换为 PDF 时 itextsharp 5.4 出现问题

c# - C#OpenFileDialog打开包含单个文件的zip文件夹?

c# - itext锐化文本提取

asp.net - iTextSharp 在 PDF 中呈现质量较差的图像

c# - 使用 Connector/NET 的关联数组/哈希/哈希表

c# - 将字典分配给键值

c# - .NET C# 中的参数化字符串

pdf - 批量打印在文本文件中列出的 PDF 文件