【问题标题】:PDFsharp - overlay page from other PDFPDFsharp - 来自其他 PDF 的叠加页面
【发布时间】:2020-03-17 10:22:12
【问题描述】:

我正在使用 PDFsharp 生成 PDF 文件,我需要将正在生成的 PDF 与另一个 PDF 的特定页面重叠。

我已经创建了这个方法:

    private void ApplyOverlay(XGraphics graph, string overlaypdfPath, int pageNumberInOverlay, XRect coordinates)
    {
        var xPdf = XPdfForm.FromFile(overlaypdfPath);

        if(xPdf.PageCount < pageNumberInOverlay)
            throw new Exception("not enough pages");

        //Here i need to take from xPdf just the page number -> pageNumberInOverlay 

        graph.DrawImage(xPdfPageN, coordinates);
    }

我不知道如何只选择特定页面。

【问题讨论】:

    标签: c# pdfsharp


    【解决方案1】:

    您可以将页码附加到 PDF 文件的名称中,并用井号 (“#”) 分隔。

    要获取“sample.pdf”的第 7 页,请使用文件名“sample.pdf#6”(从零开始的页码)。

    【讨论】:

    • 谢谢!它确实有效,但如果其他人有同样的问题,请注意:如果我想要第 7 页,我必须使用“sample.pdf#6”。它似乎像数组一样枚举页面,所以第一页是数字 0
    • 对不起,我虽然这里使用的页码是从一开始的。更新了我的答案。感谢您的反馈。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-28
    • 2022-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多