Platforms to show: All Mac Windows Linux Cross-Platform

Back to FolderItem class.

FolderItem.NewCGPDFDocumentMBS(MediaBox as CGRectMBS, title as string, author as string, creator as string) as CGPDFContextMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a PDF document.
Example
// create pdf
dim file as FolderItem = SpecialFolder.Desktop.Child("test.pdf")
dim r as new CGRectMBS(0,0,500,500)
dim c as CGContextMBS = file.NewCGPDFDocumentMBS(r, "My Title", "My Author", "My Creator")

if c<>Nil then

// create page
c.BeginPage r

// draw something
c.SetRGBFillColor(1.0, 0.0, 0.0, 1.0)
c.FillRect CGMakeRectMBS(100,100,100,100)

// close page
c.EndPage

// flush and show in PDF viewer
c = nil
file.Launch
end if

Title, author and creator are all optional.
RB 4.5 should do this perfectly, but older RB versions may have problems.
(seems like the file must exist before calling this function)
Requires Mac OS X to work.

See also:

Some examples using this method:

FolderItem.NewCGPDFDocumentMBS(MediaBox as CGRectMBS, title as string, author as string, creator as string, subject as string, keywords as string, OwnerPassword as string, UserPassword as string, AllowsPrinting as boolean, AllowsCopy as boolean) as CGPDFContextMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a PDF document.
Example
// create pdf
dim file as FolderItem = SpecialFolder.Desktop.Child("test.pdf")
dim r as new CGRectMBS(0,0,500,500)
dim c as CGContextMBS = file.NewCGPDFDocumentMBS(r, "My Title", "My Author", "My Creator", "My Subject", "test,pdf,mac", "","", true, true)

if c<>Nil then

// create page
c.BeginPage r

// draw something
c.SetRGBFillColor(1.0, 0.0, 0.0, 1.0)
c.FillRect CGMakeRectMBS(100,100,100,100)

// close page
c.EndPage

// flush and show in PDF viewer
c = nil
file.Launch
end if

Title, Author, Creator, Subject and Keywords parameters can be empty.

If OwnerPassword and UserPassword are filled in the PDF is encrypted and AllowsPrinting/AllowsCopy define what the user can do after he entered his password.

Requires Mac OS X to work.

See also:

Some examples using this method:

FolderItem.NewCGPDFDocumentMBS(MediaBox as CGRectMBS, title as string, author as string, creator as string, subject as string, keywords as string, OwnerPassword as string, UserPassword as string, AllowsPrinting as boolean, AllowsCopy as boolean, KeyLength as Integer) as CGPDFContextMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a PDF document.
Example
// create pdf
dim file as FolderItem = SpecialFolder.Desktop.Child("test.pdf")
dim r as new CGRectMBS(0,0,500,500)
dim c as CGContextMBS = file.NewCGPDFDocumentMBS(r, "My Title", "My Author", "My Creator", "My Subject", "test,pdf,mac", "owner","user", false, false, 128)

if c<>Nil then

// create page
c.BeginPage r

// draw something
c.SetRGBFillColor(1.0, 0.0, 0.0, 1.0)
c.FillRect CGMakeRectMBS(100,100,100,100)

// close page
c.EndPage

// flush and show in PDF viewer
c = nil
file.Launch
end if

Title, Author, Creator, Subject and Keywords parameters can be empty.

If OwnerPassword and UserPassword are filled in the PDF is encrypted and AllowsPrinting/AllowsCopy define what the user can do after he entered his password.

Keylength must be a value between 48 bit and 128 bit in 8 bit steps. 0 uses default value.

Requires Mac OS X to work.

See also:

Some examples using this method:

Blog Entries

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


The biggest plugin in space...