You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/CoreGraphics PDF/Getpicture PDF
Class Window1 Inherits Window
EventHandler Sub DropObject(obj As DragItem, action As Integer)
do
if obj.FolderItemAvailable then
openfile obj.FolderItem
end if
loop until not obj.NextItem
End EventHandler
EventHandler Sub Open()
me.AcceptFileDrop "special/any"
End EventHandler
Function GetPDFpicture(pdf as cgpdFDocumentMBS) As picture
dim r as CGRectMBS
dim g as CGContextMBS
dim p as Picture
// Let's get it in 400% of the size. =288 dpi
if pdf<>nil then
r=pdf.MediaBox(1)
r=CGMakeRectMBS(0,0,r.Width*4,r.Height*4)
p = new Picture(r.Width,r.Height,32)
p.Graphics.DrawCGPDFDocumentMBS pdf,r,1
Return p
end if
Exception
End Function
Sub openfile(f as folderItem)
dim p as CGPDFDocumentMBS
if f<>Nil then
p=CGOpenPDFDocumentMBS(F)
if p<>nil then
Title=f.DisplayName
Backdrop=getpdfpicture(p)
Refresh
else
MsgBox "Failed to open PDF file!"
end if
end if
End Sub
Property Protected pdf As CGPDFDocumentMBS
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class