Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
Propper Usage of QuickPDF in Visual Basic 6 |
Post Reply |
Author | |
marian_pascalau
Debenu Quick PDF Library Expert Joined: 28 Mar 06 Location: Germany Status: Offline Points: 278 |
Post Options
Thanks(0)
Posted: 02 Jan 07 at 6:37AM |
Happy New 2007 because I have lost a lot of time debuging problems caused by not checking the exit codes on UnlockKey and LoadFromFile function I decoded to publish some helper to help you in writing VB6 QuickPDF based applications.
Wen you want to create a new QuickPDF instance use:
CreateQuickPDF function
and when you want to load a new PDF document and
unload the current one (usefull with single document applications) use:
LoadDocument procedure.
Both functions/procedures throw errors when something fails !!!
Happy Programming :-)
Marian
<Module name="QPDF helper">
Attribute VB_Name = "QPDF"
Option Explicit Public Const qPDFLicenseKey = "your license key" ' Create a new QuickPDF instance
Public Function CreateQuickPDF() As iSED.QuickPDF Dim QP As iSED.QuickPDF Set QP = CreateObject("iSED.QuickPDF")
If QP.UnlockKey(qPDFLicenseKey) = 0 Then Err.Raise vbObjectError, , "Cannot unlock quickpdf library: " & QP.LicenseInfo End If Set CreateQuickPDF = QP
End Function ' Load a new PDF document
Public Sub LoadDocument(ByRef QP As iSED.QuickPDF, ByVal FileName As String) Dim nOldDoc As Long Dim nNewDoc As Long nOldDoc = QP.SelectedDocument
If QP.LoadFromFile(FileName) = 0 Then Err.Raise vbObjectError, , "Cannot open pdf document: " & FileName End If nNewDoc = QP.SelectedDocument
If QP.Encrypted > 0 Then If QP.Unencrypt = 0 Then Call QP.RemoveDocument(nNewDoc) Call QP.SelectDocument(nOldDoc) Err.Raise vbObjectError, , "Document cannot be decrypted" End If End If Call QP.RemoveDocument(nOldDoc) ' discard previous document End Sub </Module> <Module name="test QPDF module">
Public Sub PrintTest()
Call PrintDocument( _ App.Path & "\some file.pdf", _
"SomePrinter device")
End Sub Public Sub PrintDocument(ByVal FileName As String, ByVal PrintDevice As String)
On Error GoTo err_Main Dim QP As iSED.QuickPDF Dim Printeroptions As Long Dim PrintResult As Long ' Create quickPDF object Set QP = CreateQuickPDF ' Load PDF document Call LoadDocument(QP, FileName) ' Print document Printeroptions = QP.PrintOptions(0, 0, "PDF output") PrintResult = QP.PrintDocument(PrintDevice, 1, QP.PageCount, Printeroptions) MsgBox "Finished"
exit_Main: Set QP = Nothing Exit Sub err_Main: MsgBox Err.Description Resume exit_Main End Sub </Module> |
|
Michel_K17
Newbie www.exp-systems.com Joined: 25 Jan 03 Status: Offline Points: 297 |
Post Options
Thanks(0)
|
Nice!
|
|
Michel
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store