You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/CoreGraphics PDF/Show 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
EventHandler Sub Paint(g As Graphics)
dim r as CGRectMBS
if pdf<>nil then
// if you do not use the mediabox, you can strech the pdf
r=pdf.MediaBox(1)
r.Left=r.Left+100 // move
r.top=r.top+100
'r.Width=r.Width*5 // Scaling?
'r.Height=r.Height*5
'if TargetCocoa then
'dim c as CGContextMBS = GetCurrentCGContextMBS
'
'c.DrawCGPDFDocument pdf,r,1
'else
g.DrawCGPDFDocumentMBS pdf,r,1
'end if
end if
End EventHandler
Sub openfile(f as folderItem)
dim p as CGPDFDocumentMBS
if f<>Nil then
p=CGOpenPDFDocumentMBS(F)
if p<>nil then
pdf=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