Hi,
I am trying to set the state lookup in the attached PDF form (I-9 Form). The relevant Field is “State” in Section 1 of Page 1 of the Form.
Issue 1: I get an ArgumentException (Invalid font name) when I set the Selected property of the lookup. Issue 2: If I put the statement in a Try-Catch block, I can see the state set in the PDF form when opened with Adobe Acrobat Reader XI(version 11.0.06). But I can not see the state field set to the value I wanted when the output PDF form is opened with either Foxit reader (version 6.1.4) or Microsoft Reader App (Windows 8)
Issue 3: When I try to print the output PDF form from Adobe Acrobat, I get the following error: “An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem.”
The following code reproduces the Issues:
static void FillForm()
{
var pdfDoc = new Document(@“C:\Scratch\2013_I-9.pdf”);
foreach (Field field in pdfDoc.Form)
{
FindAndSetField(field);
}
pdfDoc.Save(@“C:\Scratch\2013_I-9_Filled.pdf”);
pdfDoc.Dispose();
}
private static void FindAndSetField(Field field)
{
if (field.FullName == “form1[0].#subform[6].State[0]”)
{
var cboField = (ComboBoxField) field;
foreach (var item in cboField.Options.Cast())
{
if (item.Value == “CA”)
{
try
{
cboField.Selected = item.Index;
//Issue 1: Get Argument Exception (Invalid font name).
//Issue 2: Value is visible only with Acrobat Reader. Value not visible with Foxit or Microsoft Reader (Windows 8)
//Issue 3: Error when printing the form from Acrobat Reader
}
catch (ArgumentException)
{}
break;
}
}
}
else if (field.Count > 0)
{
foreach (Field subField in field)
{
FindAndSetField(subField);
}
}
}
I am able to reproduce the issue with the following system setup:
OS: Windows 8.1
IDE: Visual Studio 2012
.Net: 4.0
Aspose.PDF: 7.9.0.0
Attachment Contents:
1. 2013_I-9.pdf: Source PDF file
2. 2013_I-9_Filled.pdf: Output PDF file generated by my program
3. PrintError.jpg: Error Shown by Acrobat when printing the output form
4. Program.cs: My test program that reproduces the issue
5. State Field causing error.jpg: Shows the Field in the PDF form causing the error.