C# 使用itext sharp在现有pdf上创建按钮

C# 使用itext sharp在现有pdf上创建按钮,c#,visual-studio-2010,itextsharp,C#,Visual Studio 2010,Itextsharp,我已经尝试了很长时间,但没有成功我有一个现有的pdf,我想加载到我当前的C#app,并想创建一个简单的按钮,请引用一些工作代码pdf的默认目录是“C:\abc.pdf” 我正在使用itextsharp,C#VS 2010 谢谢我能找到的最接近的解决方案如下 static void AddPushbuttonField(string inputFile, iTextSharp.text.Rectangle buttonPosition, string buttonName, string outp

我已经尝试了很长时间,但没有成功我有一个现有的pdf,我想加载到我当前的C#app,并想创建一个简单的按钮,请引用一些工作代码pdf的默认目录是“C:\abc.pdf”

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

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

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的经验,我认为这会起作用

资料来源:
我能找到的最接近的解决方案如下

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的经验,我认为这会起作用

资料来源:

请使用更多信息进行编辑。不鼓励只编写代码和“试试这个”答案,因为它们不包含可搜索的内容,也不解释为什么有人应该“试试这个”。我们在这里努力成为一个知识资源。请编辑更多信息。不鼓励只编写代码和“试试这个”答案,因为它们不包含可搜索的内容,也不解释为什么有人应该“试试这个”。我们努力成为知识的源泉。