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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > Sample Code
  New Posts New Posts RSS Feed - Propper Usage of QuickPDF in Visual Basic 6
  FAQ FAQ  Forum Search   Register Register  Login Login

Propper Usage of QuickPDF in Visual Basic 6

 Post Reply Post Reply
Author
Message
marian_pascalau View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 28 Mar 06
Location: Germany
Status: Offline
Points: 278
Post Options Post Options   Thanks (0) Thanks(0)   Quote marian_pascalau Quote  Post ReplyReply Direct Link To This Post Topic: Propper Usage of QuickPDF in Visual Basic 6
    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>
Back to Top
Michel_K17 View Drop Down
Newbie
Newbie
Avatar
www.exp-systems.com

Joined: 25 Jan 03
Status: Offline
Points: 297
Post Options Post Options   Thanks (0) Thanks(0)   Quote Michel_K17 Quote  Post ReplyReply Direct Link To This Post Posted: 02 Jan 07 at 10:11PM
Nice! Smile
Michel
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store