【问题标题】:Adding button in a pdf file using iTextSharp使用 iTextSharp 在 pdf 文件中添加按钮
【发布时间】:2012-02-08 12:16:51
【问题描述】:

我想使用 itextsharp 在现有 pdf 中添加一个按钮。我找到了添加文本字段的示例,但我无法获得任何示例以在 pdf 文件的特定位置添加按钮。

【问题讨论】:

    标签: c# forms pdf itextsharp field


    【解决方案1】:

    使用 PdfStamper 将 PushbuttonField 添加到现有 PDF。指定页面上的位置、字段名称和页码。

    static void AddPushbuttonField(string inputFile, iTextSharp.text.Rectangle buttonPosition, string buttonName, string outputFile)
    {
        using (PdfStamper stamper = new PdfStamper(new PdfReader(inputFile), File.Create(outputFile)))
        {
            PushbuttonField buttonField = new PushbuttonField(stamper.Writer, buttonPosition, buttonName);
    
            stamper.AddAnnotation(buttonField.Field, 1);
            stamper.Close();
        }
    }
    

    您还应该看看 iText in Action。 Chapter 8 提供了创建 PushbuttonField 的示例以及您可以设置的许多不同属性。

    【讨论】:

      猜你喜欢
      • 2015-06-23
      • 2015-05-07
      • 2014-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-01
      相关资源
      最近更新 更多