PDF Creation with Visual Basic 6.0
This example shows you how to create a PDF out of a VB6 application.
When the code is executed, the PDF engine of the PDF Maker is used for PDF generation. PDF creation takes into account the PDF settings that were previously set using the corresponding PDF Setting functions of the COM component.
After the PDF conversion has been triggered using the function convertToPDF
, the code waits for the return code of the PDF engine. This ensures that the developer knows exactly when and if the PDF generation was successfully completed.
The code sample below is available for download at the bottom of the page.
Source text extract of the source code example (VB6)
- Private Sub btnCallConvert_Click()
- 'Early binding of Var SevenPDFComObj: Please select TypeLibrary "SevenPDFComObj Library" over Project -> References, first!
- Dim SevenPDFComObj As New SevenPDFComObj.SevenPDFObjConverter
- e = 0
- On Error GoTo err_handler
- '******* INITIALIZATION *********
- SevenPDFComObj.Init
- 'SevenPDFComObj.UnlockKey ("INSERT LICENSEKEY")
- '********************************
- '****** Customize some PDF Settings *******
- 'Notice: PDF encryption works only in registered version
- '******************************************
- SevenPDFComObj.setExportNotes (0)
- SevenPDFComObj.setExportNotesPages (0)
- SevenPDFComObj.setExportBookmarks (0)
- 'Set PDF Security Options
- 'SevenPDFComObj.setEncryptFile (1)
- 'SevenPDFComObj.setPermissionPassword ("test1232")
- 'SevenPDFComObj.setRestrictPermissions (1)
- 'SevenPDFComObj.setChanges (0)
- 'SevenPDFComObj.setPrinting (1)
- 'SevenPDFComObj.setEnableCopyingOfContent (0)
- 'SevenPDFComObj.setEnableTextAccessForAccessibilityTools (0)
- 'Make the Conversion
- txtReturncode.Text = CStr(SevenPDFComObj.convertToPdf(txtFile.Text, txtPDF.Text, 0))
- Exit Sub
- err_handler:
- MsgBox "Unvorhergesehener Fehler in Modul" & Chr(10) & Chr(13) _
- & "Beschreibung: " & Err.Description & "", vbExclamation, "Runtime - Error: " & Err.Number & ""
- Exit Sub
- End Sub
- Private Sub btnSelect_Click()
- With CommonDialog1
- .FileName = ""
- .Filter = "All supported Files (*.*)|*.*|Microsoft Office 2007 Files (*.docx;*.xlsx;*.pptx)|*.docx;*.xlsx;*.pptx|Microsoft Office Files (*.doc;*.xls;*.ppt)|*.doc;*.xls;*.ppt|OpenOffice.org 1.0 Files (*.sxw;*.sxc;*.swi)|*.sxw;*.sxc;*.swi|OpenDocument Files (*.odt;*.ods;*.odp;*.odg;*.odf)|*.odt;*.ods;*.odp;*.odg;*.odf|StarOffice Files (*.sdw;*.sdc;*.swi;*.smf;*.vor)|*.sdw;*.sdc;*.swi;*.smf;*.vor|Text based Files (*.rtf;*.txt;*.csv)|*.rtf;*.txt;*.csv|Web based Files (*.htm;*.html;*.xml)|*.htm;*.html;*.xml|Maths Files (*.mml;*.odf;*.sxm;*.smf)|*.mml;*.odf;*.sxm;*.smf|Image Files (*.eps;*.tif;*.jpg;*.jpeg;*.png;*.gif;*.bmp)|*.eps;*.tif;*.jpg;*.jpeg;*.png;*.gif;*.bmp|AutoCAD / Data Interchange Formats (*.dxf;*.dif)|*.dxf;*.dif" 'Sets the filter
- .ShowOpen
- End With
- txtFile.Text = CommonDialog1.FileName
- End Sub
- Private Sub btnSelectPDF_Click()
- With Me.CommonDialog1
- .Filter = "PDF File (*.pdf)|*.pdf"
- .FileName = "output.pdf"
- .DefaultExt = "pdf"
- .ShowSave
- End With
- txtPDF.Text = CommonDialog1.FileName
- End Sub
Downloads
Attachment | Size |
---|---|
Download the code sample | 3.82 KB |