相关疑难解决方法(0)

C#:使用 PDFsharp 创建 PDF 表单 (AcroForm)

如何将 PDF 表单元素添加到 PDFsharpPdfPage对象?

我知道 AcroForm 是可填写表单的 PDF 元素的最佳格式,但 PDFsharp 库似乎不允许您创建 AcroForm 对象的实例。

我已经能够使用 PDFsharp 生成简单的文档,如下所示:

static void Main(string[] args) {
    PdfDocument document = new PdfDocument();
    document.Info.Title = "Created with PDFsharp";

    // Create an empty page
    PdfPage page = document.AddPage();

    // Draw Text
    XGraphics gfx = XGraphics.FromPdfPage(page);
    XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
    gfx.DrawString("Hello, World!", font, XBrushes.Black,
        new XRect(0, 0, page.Width, page.Height), XStringFormats.Center);

    // Save document
    const string filename = "HelloWorld.pdf";
    document.Save(filename);
}
Run Code Online (Sandbox Code Playgroud)

但我不知道如何添加可填写的表单元素。我猜它可能会使用该page.Elements.Add(string key, PdfItem …

c# pdf pdfsharp

8
推荐指数
1
解决办法
5968
查看次数

标签 统计

c# ×1

pdf ×1

pdfsharp ×1