vb.net – itextsharp:如何添加新页面并写入?

前端之家收集整理的这篇文章主要介绍了vb.net – itextsharp:如何添加新页面并写入?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在vb.net中,我填写了pdf文档的第一页,我如何从第二页开始?
Document document = new Document(PageSize.A4,50,50);
System.IO.MemoryStream msReport = new System.IO.MemoryStream();

try {
    // creation of the different writers
    PdfWriter writer = PdfWriter.GetInstance(document,msReport);

    // we add some Meta information to the document
    document.AddTitle("My Title");  
    document.AddAuthor("Me");
    document.Open();

    for (int i = 1; i <= 5; i++)
    {
        document.NewPage();
        iTextSharp.text.Table datatable = new iTextSharp.text.Table(3);
        datatable.Padding = 2;
        datatable.Spacing = 0;
        float[] headerwidths = { 6,20,32 };
        datatable.Widths = headerwidths;
        datatable.DefaultHorizontalAlignment = Element.ALIGN_LEFT;
        datatable.AddCell(i.ToString());
        datatable.AddCell("This is my name.");
        datatable.AddCell("0123456789");

        datatable.AddCell("No");
        datatable.AddCell("Yes");
        datatable.AddCell("No");

        document.Add(datatable);
     } 
} 
catch (Exception e) { 
    Console.Error.WriteLine(e.Message); 
} 

// we close the document 
document.Close(); 

Response.Clear(); 
Response.AddHeader("content-disposition","attachment;filename=Export.pdf"); 
Response.ContentType = "application/pdf"; 
Response.BinaryWrite(msReport.ToArray()); 
Response.End();
原文链接:https://www.f2er.com/vb/255379.html

猜你在找的VB相关文章