Hello, I'm having an issue with MultiLineText fields set to font size AUTO after data merge. The resulting text appearance has an excessive size font.
l_pdfForm.Save("c:\temp\TestForm_FillField_result.pdf")
Test Case
PDF Form with 1 full page sized MultiLineText field with font size set to AUTO
Info
Win7 64bit
.NET 2.0
Aspose.PDF.dll v8.5.0.0 for .NET 2.0
Expected Result
In Adobe Acrobat Pro, when editing or filling PDF Form containing a multiline text field with size AUTO, the text maintains a font size of default (12) until the text fills the field at which point the text size will gradually reduce to accomodate all the text. This is true for manual entry and import XFDF.
Code Sample 1
Dim l_pdfForm As Aspose.Pdf.Facades.Form = Nothing
l_pdfForm = New Aspose.Pdf.Facades.Form("c:\temp\testform.pdf")
Using l_memoryStream As New MemoryStream( System.Text.Encoding.UTF8.GetBytes("c:\temp\testform_data.xfdf"))
l_pdfForm.ImportXfdf(l_memoryStream)
End Using
l_pdfForm.Save("c:\temp\TestForm_ImportXFDF_result.pdf")
Code Sample 2
Dim l_pdfForm As Aspose.Pdf.Facades.Form = Nothing
Dim l_fieldName As String = String.Empty
Dim l_fieldPath As String = String.Empty
Dim l_fieldIndex As Integer = 0
Dim l_xfdfDoc As XmlDocument = Nothing
Dim l_nsManager As XmlNamespaceManager = Nothing
Dim l_xfdfNav As XPathNavigator = Nothing
Dim l_xfdfNodeNav As XPathNavigator = Nothing
l_pdfForm = New Aspose.Pdf.Facades.Form("c:\temp\testform.pdf")
l_xfdfDoc = New XmlDocument()
l_xfdfDoc.Load("c:\temp\testform_data.xfdf")
l_nsManager = New XmlNamespaceManager(l_xfdfDoc.NameTable)
l_nsManager.AddNamespace("x", "http://ns.adobe.com/xfdf/")
l_xfdfNav = l_xfdfDoc.CreateNavigator()
For l_fieldIndex = 0 To l_pdfForm.FieldNames.Length - 1
l_fieldName = l_pdfForm.FieldNames(l_fieldIndex)
l_fieldPath = "//x:field[@name='" + String.Join("']/x:field[@name='", l_fieldName.Split("."c)) + "']/x:value"
l_xfdfNodeNav = l_xfdfNav.SelectSingleNode(l_fieldPath, l_nsManager)
If l_xfdfNodeNav IsNot Nothing Then
l_pdfForm.FillField(l_fieldName, l_xfdfNodeNav.Value)
End If
Next
l_pdfForm.Save("c:\temp\TestForm_FillField_result.pdf")
Actual Result
See attached ZIP containing the following files:
- TestForm.pdf (base PDF Form used as the template)
- TestForm_data.xfdf (XFDF data to be used for the form merge)
- TestForm_ImportXFDF_result.pdf (Result of Code Sample 1)
- TestForm_FillField_result.pdf (Result of Code Sample 2)
If you edit the field in Adobe Acrobat Pro, the font returns to normal.
I attempted to fix appearance with the following but no success:
l_pdfEditor.Document.Form.Fields(l_fieldIndex).FitIntoRectangle = False
l_pdfEditor.Document.Form.Fields(l_fieldIndex).DefaultAppearance.FontSize = 12
I have also tried this with the latest Aspose.Pdf.dll v10.6.0.0 but I have the same problem.
How can I enforce a maximum size font (12) for a single line value of text in a multiline text field set to AUTO size?
NOTE: The font auto size behavior was working correctly in old style "importXfdf" using Aspose.Pdf.Kit.dll v 4.8.0.0.