1

私は長い間試みてきましたが、成功しませんでした。現在の C# アプリにロードしたい既存の pdf があり、それに単純な pusbutton を作成したいのですが、いくつかの作業コードを引用してください。pdf のデフォルト ディレクトリは "C:\ 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 に答える