Platforms to show: All Mac Windows Linux Cross-Platform
/MacOSX/CoreGraphics PDF/PDF Viewer White on Black
Feedback.
Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /MacOSX/CoreGraphics PDF/PDF Viewer White on Black
This example is the version from Sun, 3rd Oct 2009.
Notes: Last modified: Sun, 3rd Oct 2009
Feedback.
Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /MacOSX/CoreGraphics PDF/PDF Viewer White on Black
This example is the version from Sun, 3rd Oct 2009.
Notes: Last modified: Sun, 3rd Oct 2009
Class ViewerWindow
Inherits Window
// Controls
ControlInstance
Sub Paint(g As Graphics) Handles Event
drawed=true
g.DrawPicture pic,0,0
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
CurrentPage=1
updatepage
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
CurrentPage=CurrentPage-1
updatepage
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
CurrentPage=CurrentPage+1
updatepage
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
CurrentPage=PageCount
updatepage
End Sub
End ControlInstance
ControlInstance
Sub Change() Handles Event
if me.ListIndex=0 then
BackColor=&cFFFFFF
else
BackColor=&c000000
end if
UpdatePage
End Sub
End ControlInstance
ControlInstance
Sub Change() Handles Event
UpdatePage
End Sub
End ControlInstance
// Properties
Protected Dim pdf As CGPDFDocumentMBS
Dim pic As Picture
Dim CurrentPage As Integer
Dim PageCount As Integer
Dim p As CGPDFDocumentMBS
Dim drawed As Boolean
// Event implementations
Sub DropObject(obj As DragItem)
do
if obj.FolderItemAvailable then
openfile obj.FolderItem
end if
loop until not obj.NextItem
End Sub
// Methods
Sub openfile(f as folderItem)
if f<>Nil then
p=CGOpenPDFDocumentMBS(F)
if p<>nil then
Title=f.DisplayName
PageCount=p.PageCount
CurrentPage=1
UpdatePage
else
MsgBox "Failed to open PDF file!"
end if
end if
End Sub
Function GetPDFpicture(pdf as cgpdFDocumentMBS) As picture
dim r as CGRectMBS
dim g as CGContextMBS
dim pic as Picture
if pdf<>nil then
dim f as Double = 1.0
Select case PopupMenu2.ListIndex
case 0
f=1.0
case 1
f=1.25
case 2
f=1.5
case 3
f=1.75
case 4
f=2.0
end Select
r=pdf.MediaBox(1)
r=CGMakeRectMBS(0,0,r.Width*f,r.Height*f)
pic=NewPicture(r.Width,r.Height,32)
pic.Graphics.DrawCGPDFDocumentMBS pdf,r,CurrentPage
Select case PopupMenu1.ListIndex
case 0
Return pic
case 1
Return pic.InvertMBS
case 2
return pic.InvertGrayMBS
case 3
dim m as Picture = pic.ExtractColorRectangleMaskMBS
dim i as Picture = pic.InvertMBS
pic.Mask.Graphics.DrawPicture m,0,0
i.Graphics.DrawPicture pic,0,0
Return i
end Select
end if
Exception
End Function
Sub UpdateButtons()
FirstButton.Enabled=CurrentPage>1
PrevButton.Enabled=CurrentPage>1
NextButton.Enabled=CurrentPage<PageCount
LastButton.Enabled=CurrentPage<PageCount
End Sub
Sub UpdatePage()
drawed=False
pic = getpdfpicture(p)
Width=pic.Width+40
Height=pic.Height+68
UpdateButtons
if not drawed then
canvas1.Graphics.DrawPicture pic,0,0
end if
End Sub
End Class
Class App
Inherits Application
// Event implementations
Sub OpenDocument(item As FolderItem)
dim w as new ViewerWindow
w.openfile item
End Sub
Sub NewDocument()
if DebugBuild then
dim file as FolderItem = SpecialFolder.Desktop.Child("test.pdf")
if file<>Nil and file.Exists then
OpenDocument file
end if
end if
End Sub
End Class
See also:
- /MacOSX/CoreGraphics Bitmap
- /MacOSX/CoreGraphics DirectDisplay/Capture Screen
- /MacOSX/CoreGraphics DirectDisplay/CG Displaylist
- /MacOSX/CoreGraphics DirectDisplay/CG Modelist
- /MacOSX/CoreGraphics DirectDisplay/Gamma Test
- /MacOSX/CoreGraphics PDF/Create PDF with Picture
- /MacOSX/CoreGraphics PDF/Getpicture PDF
- /MacOSX/CoreGraphics PDF/PDF Fontfamily list
- /MacOSX/CoreGraphics PDF/PDF Font list
- /MacOSX/CoreGraphics PDF/PDF properties
- /MacOSX/CoreGraphics PDF/PDF Text
- /MacOSX/CoreGraphics PDF/PDF Transparency
- /MacOSX/CoreGraphics PDF/PDF using Save and Restore
- /MacOSX/CoreGraphics PDF/PDF with pathes
- /MacOSX/CoreGraphics PDF/PDF with pathes and gradient
- /MacOSX/CoreGraphics PDF/Show PDF
- /MacOSX/CoreGraphics PDF/Simple Make PDF
- /MacOSX/CoreGraphics Rendering/sofaGX in window