在页面中渲染PDF并获取表单域

时间:2012-05-10 09:24:15

标签: c# asp.net pdf

我想在我的webform页面中呈现pdf,并且pdf有多个表单字段,因此用户将从页面本身填充这些字段,并且还希望这些字段值在我的webform帖子中点击按钮。

1 个答案:

答案 0 :(得分:0)

尝试iTextSharp,它具有填写表单的功能。

  PdfReader reader = new PdfReader(@"c:\existing.pdf");

    FileStream out = new FileStream(@"C:\newForm.pdf", FileMode.Create, FileAccess.Write);

    PdfStamper stamp = new PdfStamper(reader, out);           

    TextField field = new TextField(stamp.Writer, new iTextSharp.text.Rectangle(40, 500, 360, 530), "some_text");

   // add the field here, the second param is the page number  you want it on         
    stamp.AddAnnotation(field.GetTextField(), 1);

    stamp.FormFlattening = true; // lock fields and prevent further edits.

    stamp.Close();

访问此网站以获取教程Pdf Form filling c#