We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cant find PreserveFormField property


I cant find the PreserveFormField property in the SaveOptions class. I am trying to export word to pdf and be able to get the form fields on the pdf, but its not working, there are no fields in the pdf, this is my c# code:

Aspose.Words.Document doc = new Aspose.Words.Document(strWordFilePath);
Aspose.Words.Saving.SaveOptions objSaveOptions = Aspose.Words.Saving.SaveOptions.CreateSaveOptions(Aspose.Words.SaveFormat.Pdf);

Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);

builder.InsertTextInput("txtFileInputTest", Aspose.Words.Fields.TextFormFieldType.Regular, "", "Hello", 0);

// Save the document in PDF format.
doc.Save(strPDFFilePath, objSaveOptions);

And this is the code for getting the acro form fields, using itextsharp, the pdf form does not contain any field

PdfReader pdfReader = new PdfReader(strPDFFilePath);`
MemoryStream ms = new MemoryStream();
PdfStamper pdfStamper = new PdfStamper(pdfReader, ms, ' ', true);
AcroFields pdfFormFields = pdfStamper.AcroFields;

The value of pdfFormFields.Fields.Count is 0, document does not contain fields

What do i do wrong?

Thank you very much,

@TomerZa PreserveFormField property is in PdfSaveOptions. Please see PdfSaveOptions.PreserveFormField.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Write("Please select a fruit: ");

// Insert a combo box which will allow a user to choose an option from a collection of strings.
builder.InsertComboBox("MyComboBox", new[] { "Apple", "Banana", "Cherry" }, 0);

PdfSaveOptions pdfOptions = new PdfSaveOptions();
pdfOptions.PreserveFormFields = true;

doc.Save("out.pdf", pdfOptions);

Great, i found it in the PdfSaveOptions, it works, thank you very much!

1 Like