1

我已经尝试了很长时间,但没有成功abc.pdf”。

我正在使用 itextsharp,C# VS 2010 谢谢

4

2 回答 2

1

我能找到的最接近的解决方案如下所示。

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();
    }
}

这来自这里,但没有被列为解决方案。代码看起来不错,根据我对 itextsharp 的经验,我认为这可以解决问题。

来源: 使用 iTextSharp 在 pdf 文件中添加按钮

于 2012-11-24T13:28:10.250 回答
0
Rectangle _rect;
                        _rect = new Rectangle(50, 100, 100, 100);
                        PushbuttonField button = new PushbuttonField(writer, _rect, "button");
                        PdfAnnotation widget = button.Field;
                        button.BackgroundColor = new GrayColor(0.75f);
                        button.BorderColor = GrayColor.GRAYBLACK;
                        button.BorderWidth = 1;
                        button.BorderStyle = PdfBorderDictionary.STYLE_BEVELED;
                        button.TextColor = GrayColor.GRAYBLACK;
                        button.FontSize = 11;
                        button.Text = "Text";
                        button.Layout = PushbuttonField.LAYOUT_ICON_LEFT_LABEL_RIGHT;
                        button.ScaleIcon = PushbuttonField.SCALE_ICON_ALWAYS;
                        button.ProportionalIcon = true;
                        button.IconHorizontalAdjustment = 0;
于 2016-09-30T12:48:12.933 回答