Step 3: Select Tools - Options... , select Control tabs, select Image Viewer CP Pro 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 Pro ActiveX Control, drag it on form.

Step 8: Add one combo box, 3 textbox , one button and 4 label on form, the screen like the following picture

Step 9: Select Image Viewer CP Pro ActiveX on form, change the name to ImageViewer1.
Step 10: In Form init event, add the following
Step 11: In Create PDF button click event, add the following code
thisform.ImageViewer1.PDFWriterClearAll
strFont = thisform.Combo1.List(thisform.Combo1.ListIndex)
*add A4 page
thisform.ImageViewer1.PDFWriterAddPage( 4, .F.)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .T., .F., .F., 450, 50, thisform.text1.value, 30, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .T., .F., .F., 450, 110, "Date:", 12, 0, 0, 0)
strPath=sys(5) sys(2003) "company-invoice-logo.jpg"
*invoice logo
thisform.ImageViewer1.PDFWriterDrawImage (0, strPath, 10, 100, 0.5, 0.5)
*draw sample date
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 490, 110, thisform.text2.value, 12, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .T., .F., .F., 450, 90, "Invoice No.:", 12, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .T., .F., .F., 40, 150, "Bill To:", 12, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .T., .F., .F., 40, 200, "Name:", 12, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .T., .F., .F., 40, 250, "Address:", 12, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .T., .F., .F., 40, 300, "Email:", 12, 0, 0, 0)
*draw sample company
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 96, 150, thisform.text3.value, 12, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawRectange (0, 40, 380, 550, 35, 1, 74, 74, 74, .T.)
*draw caption
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .T., .F., .F., 40, 365, "DESCRIPTION", 18, 255, 255, 255)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .T., .F., .F., 250, 365, "UNIT", 18, 255, 255, 255)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .T., .F., .F., 350, 365, "UNIT PRICE", 18, 255, 255, 255)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .T., .F., .F., 500, 365, "AMOUNT", 18, 255, 255, 255)
*draw item 1
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 40, 400, "Item 1", 20, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 250, 400, "1", 20, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 350, 400, "100.00", 20, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 500, 400, "$100.00", 20, 0, 0, 0)
*draw item 2
thisform.ImageViewer1.PDFWriterDrawText ( 0, strFont, .F., .F., .F., 40, 430, "Item 2", 20, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 250, 430, "2", 20, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 350, 430, "100.00", 20, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 500, 430, "$200.00", 20, 0, 0, 0)
*draw item 3
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 40, 460, "Item 3", 20, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 250, 460, "2", 20, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 350, 460, "200.00", 20, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 500, 460, "$400.00", 20, 0, 0, 0)
*draw item 4
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 40, 490, "Item 4", 20, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 250, 490, "1", 20, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 350, 490, "500.00", 20, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 500, 490, "$500.00", 20, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawLine (0, 40, 498, 550 40, 495, 1, 0, 0, 0)
* draw total
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .T., .F., .F., 40, 540, "TOTAL", 18, 0, 0, 0)
thisform.ImageViewer1.PDFWriterDrawText (0, strFont, .F., .F., .F., 496, 540, "$1200.00", 20, 0, 0, 0)
strOutputPDF =GETFILE('pdf', 'Browse output file', 'OK', 1, 'Save')
bResult = thisform.ImageViewer1.PDFWriterCreatePDF(strOutputPDF, "my creator", "my author", "my title", "my subject", "my keywords", "my producer")
If bResult Then
=MessageBox("PDF Created")
EndIf
Step 11: Now run the project, click Create PDF button, it can generate the PDF Invoice.
Download this sample source code