Platforms to show: All Mac Windows Linux Cross-Platform

/PDFlib/pdi pdf info
Feedback.

Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /PDFlib/pdi pdf info
This example is the version from Fri, 25th Feb 2010.
Notes: Last modified: Fri, 25th Feb 2010
Class Window1
Inherits Window
// Controls
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance

// Event implementations
Sub DropObject(obj As DragItem)
do

if obj.FolderItemAvailable then
run obj.FolderItem
end if

loop until not obj.NextItem
End Sub
Sub Open()

AcceptFileDrop "application/pdf"


End Sub

// Methods
Sub run(f as folderItem)
dim doc, page as integer
dim sheetwidth, sheetheight as single
dim p as PDFLibMBS
dim e,font as integer
dim tempfile as FolderItem

filename.text=f.Name

if not p.APIloaded then

// version 6:

if TargetMachO then
e=p.LoadFramework(getfolderitem("PDFlib.framework"))
elseif TargetWin32 then
e=p.LoadDLL("PDFlib.dll")
end if

if e<>0 then
MsgBox "LoadAPI: "+str(e)+EndOfLine+EndOfLine+"You need the PDFLib library in the correct place. Check the source code!"
quit
end if

end if

p=new PDFLibMBS

p.SetParameter("compatibility", "1.4") // for compatibility to older and newer Acrobat Readers.

tempfile=GetTemporaryFolderItem

if p.openFile(tempfile)<>-1 then

doc = p.openPDI(f, "")

if doc>=0 then

pagecount.text=str(p.GetValuePDI("/Root/Pages/Count",doc,-1,0))
pdfversion.text=str(p.GetValuepdi("version",doc,-1,0)/10)

page = p.OpenPDIPage(doc, 1, "")

if page>=0 then
pdfwidth.text=str(p.GetValuepdi("width",doc,page,0))
pdfheight.text=str(p.GetValuepdi("height",doc,page,0))
pdfrotate.text=str(p.GetValuepdi("/Rotate",doc,page,0))
else
pdfwidth.text="n/a"
pdfheight.text="n/a"
pdfrotate.text="n/a"
end if

else
msgbox "Couldn't open PDF input file input.pdf."
end if

// Write some text so no exception will raise because of an empty PDF document

p.BeginPage 200,200
font=p.FindFont("Helvetica","host",0)
p.SetFont font,10
p.ShowXY "nothing",100,100 // avoid exception
p.EndPage
p.close

end if


Exception ex as PDFLibExceptionMBS
MsgBox "PDF Lib Exception: "+ex.ErrorMessage+" ("+str(ex.ErrorNumber)+", "+ex.FunctionName+")"

End Sub
End Class

Class App
Inherits Application
End Class





Links
MBS Realbasic Chart Plugins - Pfarrgemeinde Ministranten Nickenich