【问题标题】:How to turn the page using Itextsharp如何使用 Itextsharp 翻页
【发布时间】:2021-12-02 00:24:55
【问题描述】:

我找到了一些例子。 但是,所有示例都使用PdfReader。 我想使用PDFWriter

下面是我写的代码。

private void CreatePdf(string strPdfPath)
{
    FileStream fs = new FileStream(strPdfPath, FileMode.Create, FileAccess.Write, FileShare.None);
    Document document = new Document(PageSize.A4, 45, 45, 80, 80);
    PdfWriter writer = PdfWriter.GetInstance(document, fs);
    document.Open();
    document.AddTitle("This is Title");
    document.AddCreationDate();
    Paragraph content1 = new Paragraph("This is first Page");
    document.Add(content1);

    document.NewPage();
    Paragraph content2 = new Paragraph("This is second Page");
    document.Add(content2);
    writer.Close();
    fs.Close(); 
}

如何旋转 PDF?

【问题讨论】:

    标签: c# itext


    【解决方案1】:

    你可以同时做:

     document.open();
    // Add some content in portrait
    document.setPageSize(PageSize.A4.rotate());
    document.newPage();
    // Add some content in landscape
    document.close();
    

    【讨论】:

    • 哇,这很简单!谢谢。
    • @LeandroBardelli 你知道支持.net 5 的itextSharp 版本吗?
    • @LeandroBardelli 当然。
    猜你喜欢
    • 2011-08-30
    • 2011-09-14
    • 2011-01-31
    • 2018-05-25
    • 2015-05-14
    • 2019-05-12
    • 1970-01-01
    • 1970-01-01
    • 2012-07-03
    相关资源
    最近更新 更多