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 - LoadPDFFileAsBM - returns VB picture
  FAQ FAQ  Forum Search   Register Register  Login Login

LoadPDFFileAsBM - returns VB picture

 Post Reply Post Reply
Author
Message
faypj View Drop Down
Beginner
Beginner


Joined: 01 Sep 06
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote faypj Quote  Post ReplyReply Direct Link To This Post Topic: LoadPDFFileAsBM - returns VB picture
    Posted: 02 Sep 06 at 9:52AM

A newbie to isedquickpdf:

Had looked around most of the alternatives which either were inadequate for my needs or had a hefty royalty for redistribution

Found this forum helpful so I thought I'd put a brief sample code back.

LoadPDFFileAsBM returns a VB picture containing the 1st page of a PDF file. Syntax is very similar to the VB LoadPicture function but has an optional quality setting. There probably is a slightly faster way using setdibits rather than writing to filebut below code works reliably and not too slow.

Usage:

PictureBox1= LoadPDFFileAsBM("MyPDFFile.pdf")

Public Function LoadPDFFileAsBM(FN As String, Optional PDFQuality As Integer = 72) As StdPicture
Dim QP As iSED.QuickPDF
Dim TempFN As String
Dim TempFN1 As String
TempFN = "pdf2bmp.bmp"
TempFN1 = "pdf2bmp1.bmp"
Dim succ As Long
Dim i As Integer
On Error GoTo handler:
Set QP = CreateObject("iSED.QuickPDF")
If Not IsObject(QP) Then
    MsgBox "Could not load isedquickpdf.dll"
Else
    With QP
        If .UnlockKey(PDFKey) <> 1 Then
            MsgBox "Could not unlock isedquickpdf.dll"
        Else
            Screen.MousePointer = vbHourglass
            If ThisFileExists(TempFN1) Then Kill TempFN1
            succ = .LoadFromFile(FN)
            .Unencrypt
            succ = .RenderDocumentToFile(PDFQuality, 1, 1, 0, TempFN)
           
            For i = 0 To 100
                DoEvents
                If ThisFileExists(TempFN1) Then Exit For
            Next
           
            If ThisFileExists(TempFN1) Then
               
                Set LoadPDFFileAsBM = LoadPicture(TempFN1)
                Kill TempFN1
            End If
        End If
    End With
    Set QP = Nothing
    Screen.MousePointer = vbDefault
End If
Exit Function
handler:
Select Case MsgBox("Error " & Err.Number & vbCrLf & _
Err.Description, vbAbortRetryIgnore, "Error LoadPDFFileAsBM")
Case vbRetry: Resume
Case vbIgnore: Resume Next
End Select
Set QP = Nothing
Screen.MousePointer = vbDefault
End Function

Public Function ThisFileExists(ThisFile As String) As Boolean

On Error GoTo handler:
ThisFileExists = False
GetAttr ThisFile
ThisFileExists = True
Exit Function
handler:
End Function

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