【发布时间】:2014-12-10 16:47:02
【问题描述】:
我们正在使用 ABCpdf 读取 adobe 表单模板,使用从数据库中检索到的值填充表单字段并将它们修改为单个 PDF 文档,并将文档作为 HTTP 响应中的文件流发送回 ASP.net MVC 中的用户应用程序。
这种方法运行良好,并且可以成功生成 PDF 文档。但是,当用户选择打开生成的 PDF 文件并尝试关闭它时,Adobe Acrobat 会提示他们“是否要在关闭前保存对 xxx.pdf 的更改”对话框。有什么方法可以使用 ABC pdf 来抑制这条消息?
以下是我们用来生成 PDF 的代码。
public byte[] GeneratePDF(Employee employee, String TemplatePath)
{
string[] FieldNames;
Doc theDoc;
MemoryStream MSgeneratedPDFFile = new MemoryStream();
//Get the PDF Template and read all the form fields inside the template
theDoc = new Doc();
theDoc.Read(HttpContext.Current.Server.MapPath(TemplatePath));
FieldNames = theDoc.Form.GetFieldNames();
//Navigate through each Form field and populate employee details
foreach (string FieldName in FieldNames)
{
Field theField = theDoc.Form[FieldName];
switch (FieldName)
{
case "Your_First_Name":
theField.Value = employee.FirstName;
break;
default:
theField.Value = theField.Name;
break;
}
//Remove Form Fields and replace them with text
theField.Focus();
theDoc.Color.String = "240 240 255";
theDoc.FillRect();
theDoc.Rect.Height = 12;
theDoc.Color.String = "220 0 0";
theDoc.AddText(theField.Value);
theDoc.Delete(theField.ID);
}
return theDoc.GetData();
}
【问题讨论】:
-
也在寻找这个问题的答案...
-
这是最近(2016 年)Adobe Reader 更新中出现的一个非常烦人的“功能”。 Adobe 声称 Reader 会在打开时检查并“修复”损坏的文件,因此——即使 Reader 不允许编辑文档——它也会“修复”它,然后提示您保存修复后的版本。虽然并非所有文档都这样做,但很多文档都会这样做,如果您是 PDF 的用户,那么节省或不保存文档会浪费您的大量时间。
-
允许阅读器修改和保存文档增加了一个“问题”,可以在 PDF 中包含“元数据”,最简单的是作者、创建者和标题。如果文档具有标题元数据,它将在使用 Chrome 阅读文档时显示,即从网站打开,但是阅读器“修改”元数据并且不再显示在 Chrome 中,这在我的文档中不是特别有用的“改进”意见?
标签: abcpdf