为什么我保存pdf xfa 的格式后,文件变大了 Document pdfDocument = new Document(FilePath);
TextBoxField? textBoxField = pdfDocument.Form["form1[0].Page1[0].autoAdr[0].ad03[0]"] as TextBoxField;
if (textBoxField != null)
{
textBoxField.Value = "Test";
textBoxField.DefaultAppearance = new DefaultAppearance("Helvetica", 10, System.Drawing.Color.Black);
}
if (!string.IsNullOrEmpty(signDateFieldName))
{
var dateField = pdfDocument.Form[signDateFieldName] as TextBoxField;
if (dateField != null)
{
dateField.Value = DateTime.Now.ToString("ddMMyyyy");
dateField.ReadOnly = true;
}
}
var opts = new OptimizationOptions
{
CompressObjects = true,
RemoveUnusedStreams = true,
RemoveUnusedObjects = true,
UnembedFonts = false,
SubsetFonts = true,
};
pdfDocument.OptimizeResources(opts);
pdfDocument.Optimize();
pdfDocument.Save("output.pdf");
pdfDocument.Dispose();