我有一个PDF文档,其中有一些填充字段(文本和复选框)。如何引用这些对象以便我可以操纵它的值,然后将更新后的PDF推送给用户,以便将它们保存到他们想要的位置。我没有找到任何有关如何做到这一点的好文件。iText文档
任何信息,你可以给我将不胜感激。
现在我正在使用以下代码,但是当我打开它时,我的PDF阅读器告诉我它已损坏或损坏。
String srcPath = Server.MapPath("~/App_Data/w9.pdf");
String dstPath = Server.MapPath("~/App_Data/w9_" + Session.SessionID + "_updated.pdf");
if (File.Exists(dstPath)) {
File.Delete(dstPath);
}
File.Copy(srcPath, dstPath);
PdfReader reader = new PdfReader(dstPath);
try
{
PdfStamper stamper = new PdfStamper(reader, Response.OutputStream);
stamper.FormFlattening = true;
stamper.AcroFields.SetField("topmostSubform[0].Page1[0].f1_01_0_[0]", "Homer J Simpson");
Response.ContentType = "application/pdf";
Response.BufferOutput = true;
Response.AppendHeader("Content-Disposition", "attachment; filename=W9_" +Session.SessionID + "_Complete.pdf");
Response.TransmitFile(dstPath);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
Jim有很多关于如何在Web上做这个的例子做Google搜索[如何枚举PDF文档中的所有字段](http://stackoverflow.com/questions/3041883/how-do-i -enumerate-所有的字段-IN-A-PDF文件功能于iTextSharp的) – MethodMan