いくつかの入力フィールド(テキストとチェックボックス)があるPDFドキュメントがあります。これらのオブジェクトを参照して、その値を操作し、更新されたPDFをユーザーにプッシュして、目的の場所に保存するにはどうすればよいですか。これを行う方法についての適切なドキュメントが見つかりません。
あなたが私に与えることができるどんな情報でも大いにありがたいです。
現在、次のコードを使用していますが、開いてみると、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);
}