Home > Products > PDF Form Filler


VeryPDF PDF Form Filler SDK user manual


Functions:

void WINAPI PDFForm_SetLicenseKey(LPCTSTR lpLicenseKey)
Description:
    Set License Key to PDF Form Filler SDK to remove restrictions.
Return value:
    No.
Parameters:
    lpLicenseKey: a License Key which issued by VeryPDF.

BOOL WINAPI PDFForm_MergeFDFIntoPDF(LPCTSTR lpInPDF, LPCTSTR lpInFDF, LPCTSTR lpOutPDF)
Description:
    Merge a FDF file into an existing PDF file and generate a new filled PDF file.
Return value:
   
TRUE is success, FALSE is fail.
Parameters:
    lpInPDF: input PDF file
    lpInFDF: input FDF file
    lpOutPDF: merged PDF file

BOOL WINAPI PDFForm_ExtractFDFFromPDF(LPCTSTR lpInPDF, LPCTSTR lpOutFDF)
Description:
    Extract FDF data from a filled PDF file.
Return value:
   
TRUE is success, FALSE is fail.
Parameters:
    lpInPDF: input PDF file
    lpOutFDF: output FDF file

BOOL WINAPI PDFForm_FlattenPDF(LPCTSTR lpInPDF, LPCTSTR lpOutPDF)
Description:
    Flatten a form filled PDF file
Return value:
   
TRUE is success, FALSE is fail.
Parameters:
    lpInPDF: input PDF file
    lpOutPDF: output PDF file

BOOL WINAPI PDFForm_EncryptPDF(LPCTSTR lpInPDF, LPCTSTR lpUserPwd, LPCTSTR lpOwnerPwd, LPCTSTR lpPermissions,
int nKeyLen, LPCTSTR lpOutPDF)
Description:
    Encrypt a PDF file.
Return value:
   
TRUE is success, FALSE is fail.
Parameters:
    lpInPDF: input PDF file
    lpUserPwd: user password
    lpOwnerPwd: owner password
    lpPermissions: set permissions, it can be following values,
                        Printing // top quality printing
                        ModifyContents = ModifyContents | Assembly
                        Copy = Copy | ScreenReaders
                        ModifyAnnotations = ModifyAnnotations | FillIn
                        FillIn
                        ScreenReaders
                        Assembly
                        DegradedPrinting
    nKeyLen: 128 or 40 bits
    lpOutPDF: output PDF file

long WINAPI PDFForm_Alloc()
Description:
    Allocate a handle for PDF Form Filling.
Return value:
    0 is an error, other values are valid IDs.
Parameters:
   
None.

long WINAPI PDFForm_Free(long id)
Description:
    Free handle of PDF Form Filling.
Return value:
   
0 is success, other values are indicate an error.
Parameters:
    id: a valid ID returned by PDFForm_Alloc() function

long WINAPI PDFForm_SetTextField(long id, LPCTSTR lpFieldName, LPCTSTR lpFieldValue)
Description:
    Set data into Text fields.
Return value:
    if return value less than zero, it is indicate an error,
    if return value large than zero, it is the number of form fields in the list.
Parameters:
    id: a valid ID returned by PDFForm_Alloc() function
    lpFieldName: form field name
    lpFieldValue: form field value

long WINAPI PDFForm_SetCheckBox(long id, LPCTSTR lpFieldName, LPCTSTR lpFieldValue)
Description:
    Set data into CheckBox fields.
Return value:
    if return value less than zero, it is indicate an error,
    if return value large than zero, it is the number of form fields in the list.
Parameters:
    id: a valid ID returned by PDFForm_Alloc() function
    lpFieldName: form field name
    lpFieldValue: form field value

long WINAPI PDFForm_Apply(long id, LPCTSTR lpInFile, LPCTSTR lpOutFile, LONG bFlatten)
Description:
    Merge form data into PDF file.
Return value:
    0 is success, other values are indicate an error
    -6: create FDF file error
    -7: import form data into PDF file error
    -8: flatten filled PDF file error
Parameters:
    id: a valid ID returned by PDFForm_Alloc() function
    lpInFile: input PDF file
    lpOutFile: output PDF file
    bFlatten: make the output file flatten or not

long WINAPI PDFForm_ClearFields(long id)
Description:
    Clear data from form fields.
Return value:
   
0 is success, other values are indicate an error.
Parameters:
    id: a valid ID returned by PDFForm_Alloc() function.


Example code:
      Private Declare Sub PDFForm_SetLicenseKey Lib "pdfform.dll" (ByVal lpLicenseKey As String)
      Private Declare Function PDFForm_MergeFDFIntoPDF Lib "pdfform.dll" (ByVal lpInPDF As String, ByVal lpInFDF As String, ByVal lpOutPDF As String) As Long
      Private
Declare Function PDFForm_ExtractFDFFromPDF Lib "pdfform.dll" (ByVal lpInPDF As String, ByVal lpOutFDF As String) As Long
      Private
Declare Function PDFForm_FlattenPDF Lib "pdfform.dll" (ByVal lpInPDF As String, ByVal lpOutPDF As String) As Long
      Private
Declare Function PDFForm_EncryptPDF Lib "pdfform.dll" (ByVal lpInPDF As String, ByVal lpUserPwd As String, ByVal lpOwnerPwd As String, ByVal lpPermissions As String, ByVal nKeyLen As Long, ByVal lpOutPDF As String) As Long
     
      Private
Declare Function PDFForm_Alloc Lib "pdfform.dll" () As Long
      Private
Declare Function PDFForm_Free Lib "pdfform.dll" (ByVal id As Long) As Long
      Private
Declare Function PDFForm_SetTextField Lib "pdfform.dll" (ByVal id As Long, ByVal lpFieldName As String, ByVal lpFieldValue As String) As Long
      Private
Declare Function PDFForm_SetCheckBox Lib "pdfform.dll" (ByVal id As Long, ByVal lpFieldName As String, ByVal lpFieldValue As String) As Long
      Private
Declare Function PDFForm_Apply Lib "pdfform.dll" (ByVal id As Long, ByVal lpInFile As String, ByVal lpOutFile As String, ByVal bFlatten As Long) As Long
      Private
Declare Function PDFForm_ClearFields Lib "pdfform.dll" (ByVal id As Long) As Long

      Private Function PDFFormFilling1()
              Dim id As Long
              Dim
nRet As Long
              Dim
szOutPDF1 As String
              Dim
szOutPDF2 As String
              Dim
szPDFFile As String
             
             
szPDFFile = App.Path + "\example-fw9.pdf"
              szOutPDF1 = App.Path + "\out1.pdf"
              szOutPDF2 = App.Path + "\out2.pdf"
     
              id = PDFForm_Alloc()
              nRet = PDFForm_SetTextField(id, "f1-1", "1 Test for Name")
              nRet = PDFForm_SetTextField(id, "f1-2", "1 Test for Business Name")
              nRet = PDFForm_SetTextField(id, "f1-3", "1 Test for f1-3")
              nRet = PDFForm_SetTextField(id, "f1-4", "1 Test for f1-4")
              nRet = PDFForm_SetTextField(id, "f1-5", "1 Test for f1-5")
              nRet = PDFForm_SetTextField(id, "f1-6", "1 Test for f1-6")
              nRet = PDFForm_SetCheckBox(id, "c1-4", "Off")
              nRet = PDFForm_SetCheckBox(id, "c1-5", "Off")
              nRet = PDFForm_SetCheckBox(id, "c1-1", "Yes")
              nRet = PDFForm_SetCheckBox(id, "c1-2", "Yes")
              nRet = PDFForm_Apply(id, szPDFFile, szOutPDF1, False)
              nRet = PDFForm_ClearFields(id)
              nRet = PDFForm_SetTextField(id, "f1-1", "2 Test for Name")
              nRet = PDFForm_SetTextField(id, "f1-2", "2 Test for Business Name")
              nRet = PDFForm_SetTextField(id, "f1-3", "2 Test for f1-3")
              nRet = PDFForm_SetTextField(id, "f1-4", "2 Test for f1-4")
              nRet = PDFForm_SetTextField(id, "f1-5", "2 Test for f1-5")
              nRet = PDFForm_SetTextField(id, "f1-6", "2 Test for f1-6")
              nRet = PDFForm_SetCheckBox(id, "c1-4", "Off")
              nRet = PDFForm_SetCheckBox(id, "c1-5", "Off")
              nRet = PDFForm_SetCheckBox(id, "c1-1", "Yes")
              nRet = PDFForm_SetCheckBox(id, "c1-2", "Yes")
              nRet = PDFForm_Apply(id, szPDFFile, szOutPDF2, True)
              nRet = PDFForm_Free(id)
      End Function
      Private Function
PDFFormFilling2()
              Dim bRet As Long
              Dim
szInPDFFile As String
              Dim
szInFDFFile As String
              Dim
szOutPDFFile As String
              Dim
szOutFDFFile As String
              Dim
szFlattenPDFFile As String
              Dim
szEncryptPDFFile As String
             
             
szInPDFFile = App.Path + "\example-fw9.pdf"
              szInFDFFile = App.Path + "\example-fw9.fdf"
              szOutPDFFile = App.Path + "\out-filled.pdf"
              szOutFDFFile = App.Path + "\out.fdf"
              szFlattenPDFFile = App.Path + "\out-flatten.pdf"
              szEncryptPDFFile = App.Path + "\out-encrypt.pdf"
             
              bRet = PDFForm_MergeFDFIntoPDF(szInPDFFile, szInFDFFile, szOutPDFFile)
              bRet = PDFForm_ExtractFDFFromPDF(szOutPDFFile, szOutFDFFile)
              bRet = PDFForm_FlattenPDF(szOutPDFFile, szFlattenPDFFile)
              bRet = PDFForm_EncryptPDF(szOutPDFFile, "123", "456", "Printing", 128, szEncryptPDFFile)
      End Function
      Private Sub
PDFForm_Click()
              PDFForm_SetLicenseKey ("XXXXXXXXXXXXXXXX")
              PDFFormFilling1
              PDFFormFilling2
      End Sub