Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCG/CoreGraphics PDF/PDF with paths
Required plugins for this example: MBS MacCG Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/CoreGraphics PDF/PDF with paths
This example is the version from Sun, 23th Sep 2017.
Project "PDF with paths.rbp"
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 Window1 Inherits Window
EventHandler Sub Open() // Original example can be found on Apple's Website. // Translation from C is quite easy ;-) dim c as CGContextMBS dim f as FolderItem dim r as CGRectMBS dim kSize, kHalfSize, kTenthSize as Single dim location(5) as CGPointMBS const kMediaHeight=100.0 const kMediaWidth=100.0 f=SpecialFolder.Desktop.Child("RB Path Demo1.pdf") r=CGMakeRectMBS(0,0,kMediaWidth,kMediaHeight) // Create the context c=CGNewPDFDocumentMBS(f,r,"PDF from Xojo","Christian Schmitz","MBS Plugin 2.7") if c<>nil then // Define the locations (relative to the origin of the // graphics context) of all five points of the star kSize=kMediaHeight*0.9 kHalfSize=kSize*0.5 kTenthSize=kSize*0.1 location(0)=CGMakePointMBS(kTenthSize,0) location(1)=CGMakePointMBS(kHalfSize,kSize-kTenthSize) location(2)=CGMakePointMBS(kSize-kTenthSize,0) location(3)=CGMakePointMBS(0,kHalfSize) location(4)=CGMakePointMBS(kSize,kHalfSize) location(5)=CGMakePointMBS(kTenthSize,0) // We must begin a new page before drawing to a PDF context c.BeginPage(r) // // Just for fun, skew the star slightly by rotating the CTM // a little bit. // // Since the rotation will otherwise cause the tip of one edge of the // star to be clipped, we translate the CTM ten units horizontally to // make sure the entire star fits on the page. // c.TranslateCTM(10,0) c.RotateCTM(0.1) // This color approximates a deep sky blue c.SetRGBFillColor 0.4,0.6,1.0,0.5 // Add the star to the path c.AddLines location c.EOFillPath // FillPath and EOFillPath always clear the path, // so we need to add the lines again to draw the star outline c.AddLines location c.StrokePath // We've finished rendering the page c.EndPage c.Flush c=nil // to force the file to be written as we want to launch it f.Launch else MsgBox "Failed to creator file!" end if quit End EventHandler
End Class
Class App Inherits Application
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacCG Plugin.

MBS Xojo Plugins