Platforms to show: All Mac Windows Linux Cross-Platform
/MacCG/CoreGraphics PDF/Show PDF
Required plugins for this example: MBS MacCG Plugin, MBS MacCF Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/CoreGraphics PDF/Show PDF
This example is the version from Sun, 17th Mar 2012.
Project "Show PDF.xojo_binary_project"
FileTypes
Filetype special/any
End FileTypes
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
End Project
See also:
- /MacCG/CoreGraphics DirectDisplay/CG Displaylist
- /MacCG/CoreGraphics DirectDisplay/CG Modelist
- /MacCG/CoreGraphics DirectDisplay/CGDisplay Rotation
- /MacCG/CoreGraphics DirectDisplay/CGDisplayMBS CreateImageAsync
- /MacCG/CoreGraphics DirectDisplay/Gamma Test
- /MacCG/CoreGraphics PDF/Create PDF with Picture
- /MacCG/CoreGraphics PDF/PDF properties
- /MacCG/CoreGraphics PDF/PDF Transparency
- /MacCG/CoreGraphics PDF/PDF using Save and Restore
- /MacCG/CoreGraphics PDF/PDF with paths
The items on this page are in the following plugins: MBS MacCG Plugin.