New Forum | Previous | Next | (P-PDF) Developers
Conf: (P-PDF) Developers, Msg: 59339
From: Andrew Kerr
Date: 5/29/2002 05:38 PM
Well, slap me silly and call me 'Marion' the solution was in front of me the whole time (well, since I downloaded the PDFlib eval library!).
An example is included in the download which demonstrates loading a jpg and converting to pdf. After a couple of runs I still didn't think it worked but after opening my eyes and 5 mins of debugging analysis I discovered that what looked to be a 'doing nothing' routine was actually doing the business better than expected so situation over and thanks to Aandi and Leonard for helping me out.
Below is the code required to load an image and save the PDF with information.
'Ensure the PDFlib_com.dll is referenced via
Dim ret As Long, font As Long
Dim oPDF As PDFlib_com.PDF
Dim imageFile As String
Dim lWidth, lHeight As Long
Dim lImage As Long
Set oPDF = New PDFlib_com.PDF
ret = oPDF.open_file("c:\dev\ak_test.pdf")
If (ret = -1) Then
MsgBox "Couldn't open PDF file!"
oPDF.set_info "Creator", "VisBasic 6.0"
oPDF.set_info "Author", "Andrew Kerr"
oPDF.set_info "Title", "Test Output via PDFlib"
imageFile = "C:\dev\test1.tif"
lImage = oPDF.open_image_file("tiff", imageFile, "", 0)
If (lImage = -1) Then
MsgBox "Couldn't open image file!"
' We generate a page with the image's dimensions
lWidth = oPDF.get_value("imagewidth", lImage)
lHeight = oPDF.get_value("imageheight", lImage)
' start a new page
oPDF.begin_page lWidth, lHeight
' Place the image in the lower left corner
oPDF.place_image lImage, 0, 0, 1
oPDF.end_page ' finish page
oPDF.Close ' close PDF document
Set oPDF = Nothing