Image Viewer CP Gold SDK ActiveX

Image Viewer CP Gold SDK ActiveX

Platform : Windows 10, Windows 8, Vista, Windows 7, XP

For Windows Developers who need to PDF TIFF Viewer and Image Viewer , plus support TIFF with WANG Annotations, securing a PDF document, add annotation with PDF for C++  , C#, VB.NET , VB, Delphi, Vfp, MS Access.

Popular Solution Go   Back

Visual Foxpro - How to Autofill PDF form fields

Step 1: To install the Image Viewer CP Gold SDK ActiveX, begin by launching the setup file (http://www.viscomsoft.com/demo/imageviewercpgoldsetup.exe). Select the desired installation folder for the Image Viewer CP Gold SDK ActiveX and continue with the installation on your development computer.

Step 2: Launch VFP - Visual Foxpro. select New Project.

Step 3: Select Tools - Options... , select Control tabs, select Image Viewer CP Gold ActiveX Control, click OK button.





Step 4: Select Forms - click New... button to add new form.



Step 5: Select form1, click Modify button.

Step 6: In Form Controls Toolbar, click View Classes button, then select ActiveX Controls.

Step 7: Now you will see the Image Viewer CP Gold ActiveX Control, drag it on form.

Step 8: Add 3 buttons , button1's caption is "Select PDF", button2's caption is "Update Name, Business Name, Address 'fields", buttno3 's caption is "Export updated fields to new PDF file" and one List Box, the screen like the following picture

Step 9: select Image Viewer CP Gold ActiveX on form, change the name to imageviewer1.

Step 10: select Form - New Method... enter GetWidgetType , then ckick Add

Step 11: In GetWidgetType method add the following code

LPARAM iType 

If iType = 0 Then

            strType = "UNKNOWN"

 endif

 

 If iType = 1 Then

            strType = "BUTTON"

 endif

 

 If iType = 2 Then

            strType = "CHECKBOX"

 endif           

 

 If iType = 3 Then

            strType = "COMBOBOX"

 endif           

  If iType = 4 Then

            strType = "LISTBOX"

 endif                 

 If iType = 5 Then

            strType = "RADIOBUTTON"

 endif                 

  If iType = 6 Then

            strType = "SIGNATURE"

  endif            

  If iType = 7 Then

            strType = "TEXT"

  endif

 

return strType

Step 12: In button1 (Select PDF) click event, add the following code

thisform.imageviewer1.PDFUseAdvancedViewer = .T.
strPDFFile = GETFILE('pdf', 'Open PDF file', 'Browse', 1, 'Select PDF file ')
thisform.imageviewer1.loadMultiPage (strPDFFile,1)
For i = 0 To thisform.imageviewer1.PDFFormFieldsCount() - 1
 
iType = thisform.imageviewer1.PDFFormFieldsWidgetType(i)
  strLabel = thisform.imageviewer1.pdfformFieldsLabel(i);
 
  If iType = 7 Then
                strValue = " Value " thisform.imageviewer1.PDFFormFieldsText(i)
  endif
  
  if iType = 3 Then
                strValue = " Selected Index " str(thisform.PDFFormFieldsCboListBoxIndex(i))
  endif
  
  if iType = 2 Then
                If thisform.imageviewer1.PDFFormFieldsIsCheck(i) = 0 Then
                    strValue = "Unchecked"
                Else
                    strValue = "Checked"
                Endif
   Endif       
   strItem = "Index " allt(str(i)) " " "Label name:" strLabel " " thisform.GetWidgetType(iType) " " strValue       
  
     thisform.list1.AddItem(strItem)
  
 next
Step 13: In button2 (Update Name, Business Name, Address 'fields), add the following code, we updated 3 text fields, the index of text field is 0,1,13 

thisform.ImageViewer1.PDFFormFieldsSetText(0, "Billy")
thisform.ImageViewer1.PDFFormFieldsSetText(1, "ABC Company")
thisform.ImageViewer1.PDFFormFieldsSetText(13, "Happy Street 10, ABC Garden")
thisform.ImageViewer1.PDFFormFieldsUpdate("")

Step 14: In button3 (Export updated fields to new PDF file), add the following code, it will save the updated data and export to new pdf.

strOutputPDF=GETFILE('pdf', 'Save PDF file', 'OK', 1, 'Select PDF file ')
thisform.ImageViewer1.PDFFormFieldsUpdate(strOutputPDF)

Step 15: Click here to Download the sample PDF file for this sample.

Step 16: Click here to Download this VFP sample project source code.

Step 17: Run the sample project, then open sample PDF file, click "(Update Name, Business Name, Address 'fields" button. Then you may Export updated fields to new PDF file.