I than ran into some problems in our project. I've been able to reproduce this issue with the code below
I've written the following program:
- Code: Select all
public static string TemplateName = "test.docx";
public static string OutputDocx = "testOut.DOCX";
public static string OutputPdf = "testOut.pdf";
public void TestFormFields()
{
byte[] template = File.ReadAllBytes(TemplateName);
Document document = new Document(new MemoryStream(template));
for (int i = 0; i < document.Sections.Count; i++)
{
foreach (FormField field in document.Sections[i].Body.FormFields)
{
field.Text = "IsThisTextVisible";
}
}
document.SaveToFile(OutputDocx, FileFormat.Docx);
ToPdfParameterList toPdf = new ToPdfParameterList();
if (document.BuiltinDocumentProperties.Company == null)// Spire.Doc crashes when this property = null
{
document.BuiltinDocumentProperties.Company = "";
}
document.SaveToFile(OutputPdf, toPdf);
}
When I open the generated "testOut.docx", all formfields are correctly visible and show the text "IsThisTextVisible".
However, when I open the "testOut.pdf", all formfields show up empty.
If you have any more question about this problem, please let me know.
Kind regards,
Marcel