When text is entered in a form field that is separated by blank lines, the blank lines are moved to the end of the text during PDF export with the “PreserveFormFields” option enabled. If the “PreserveFormFields” option is disabled, the order remains unchanged.
Aspose.Words-Version: 24.7.0
using System.Diagnostics;
using Aspose.Words;
using Aspose.Words.Fields;
using Aspose.Words.Saving;
using MoreLinq;
const string templatePath = @"path\to\form-test.docx";
const string outputPath = @"output\path\form-test.pdf";
Document document;
using (FileStream stream = File.Open(templatePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
document = new Document(stream);
}
FormFieldCollection formsFields = document.Range.FormFields;
formsFields.ForEach(formField => {
formField.Enabled = false;
});
PdfSaveOptions saveOptions = new() {
Compliance = PdfCompliance.Pdf20,
PreserveFormFields = true
};
document.Save(outputPath, saveOptions);
ProcessStartInfo startInfo = new() {
FileName = outputPath,
UseShellExecute = true
};
Process.Start(startInfo);
Template: template.zip (9.3 KB)