The following download contains an example demonstrating how to set a field's text alignment to centered, left, right, or fully justified. When changing field properties, it is necessary to temporarily store the field data, as shown in the example, then add the data again with SetFormFieldData once the properties have been set. The call to CopyForm will then propagate the changes to the new output file.
NOTE: This example is available in other scripts. Select from the Code Samples list above to display the download link for the example in the language appropriate for your programming environment.
Click below to download this example for VBScript. Download contains all required files
' Instantiate Object
Set TK = CreateObject("APToolkit.Object")
' OpenOutputFile
varReturn = TK.OpenOutputFile(varRightJustifiedFile)
If varReturn <> 0 Then Error("OpenOutputFile") End If
' OpenInputFile
varReturn = TK.OpenInputFile(varInputFile)
If varReturn <> 0 Then Error("OpenInputFile") End If
' Store the data in the field who's alignment you are changing.
fieldData = TK.GetFormFieldDataByName(varField)
' Set the field's alignment to right justified
Set FIO = TK.FieldInfo(varField, 1)
FIO.Alignment = 2 'Left = 0, Centered = 1, and full justification = 3
' Set the field data
TK.SetFormFieldData varField, fieldData, 1
' CopyForm
varReturn = TK.CopyForm (0, 0)
If varReturn <> 1 Then Error("CopyForm") End If
The information in this article is for the use of activePDF Customers and Evaluation Users Only. No part of this document may be transmitted or reproduced without the express written consent of activePDF.