Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

CGNewPDFDocumentMBS(file as folderitem, MediaBox as CGRectMBS, title as string, author as string, creator as string) as CGPDFContextMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method CoreGraphics MBS MacCG Plugin 12.0 Yes No No Yes, macOS only No
Function: Creates a PDF document.
Notes:
Title, author and creator are all optional.
Requires Mac OS X to work.

Some examples using this method:

Feedback, Comments & Corrections

CGOpenPDFDocumentMBS(file as folderitem) as CGPDFDocumentMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method CoreGraphics MBS MacCG Plugin 2.7 Yes No No Yes, macOS only No
Function: Opens a PDF document.
Notes:
RB 4.5 should do this perfectly, but older RB versions may have problems with longer file names.
Requires Mac OS X to work.

Some examples using this method:

Feedback, Comments & Corrections

Folderitem.NewCGPDFDocumentMBS(MediaBox as CGRectMBS, title as string, author as string, creator as string) as CGPDFContextMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 12.0 Yes No No Yes, macOS only No
Function: 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
Notes:
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 which use this method:

Feedback, Comments & Corrections

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 Console & Web iOS
method CoreGraphics MBS MacCG Plugin 12.0 Yes No No Yes, macOS only No
Function: 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
Notes:
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 which use this method:

Feedback, Comments & Corrections

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 Console & Web iOS
method CoreGraphics MBS MacCG Plugin 12.0 Yes No No Yes, macOS only No
Function: 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
Notes:
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 which use this method:

Feedback, Comments & Corrections

folderitem.NewCGPDFDocumentWithInfoMBS(MediaBox as CGRectMBS, info as object) as CGPDFContextMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 12.0 Yes No No Yes, macOS only No
Function: 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 d as new CFMutableDictionaryMBS

d.Add NewCFStringMBS("kCGPDFContextTitle"), NewCFStringMBS("My Title")
d.Add NewCFStringMBS("kCGPDFContextAuthor"), NewCFStringMBS("My Author")
d.Add NewCFStringMBS("kCGPDFContextCreator"), NewCFStringMBS("My Creator")
d.Add NewCFStringMBS("kCGPDFContextSubject"), NewCFStringMBS("My Subject")
d.Add NewCFStringMBS("kCGPDFContextKeywords"), NewCFStringMBS("keyword,mac,pdf")

dim c as CGContextMBS = file.NewCGPDFDocumentWithInfoMBS(r, d)

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
Notes:
The optional info parameter is a CFDictionaryMBS object and contains some information about the PDF file.

Keys for auxiliary info dictionary:

NewCFStringMBS("kCGPDFContextTitle")
The document's title. Optional; if present, the value must be a CFString.

NewCFStringMBS("kCGPDFContextAuthor")
The name of the person who created this document. Optional; if present, the value must be a CFString.

NewCFStringMBS("kCGPDFContextCreator")
The name of the application that created the original data used to create this document. Optional; if present, the value must be a CFString.

NewCFStringMBS("kCGPDFContextOutputIntent")
The document's output intent. Optional; if present, the value must be a CFDictionaryMBS. The dictionary is added to the PDF document in the /OutputIntents entry in the PDF file's document catalog. The keys and values contained in the dictionary must match those specified in section 9.10.4 of the PDF 1.4 specification, ISO/DIS 15930-3 document published by ISO/TC 130, and Adobe Technical Note #5413.

The following keys are supported:

"S" - The output intent subtype. This key is required; the value must be a CFString equal to "GTS_PDFX"; otherwise, the dictionary is ignored.

"OutputConditionIdentifier" - A string identifying the intended output device or production condition in a human- or machine-readable form. This key is required; the value must be a CFString. For best results, the string should be representable losslessly in ASCII encoding.

"OutputCondition" - A text string identifying the intended output device or production condition in a human-readable form. This key is optional; if present, the value must be a CFString.

"RegistryName" - A string identifying the registry in which the condition designated by "OutputConditionIdentifier" is defined. This key is optional; if present, the value must be a CFString. For best results, the string should be representable losslessly in ASCII encoding.

"Info" - A human-readable text string containing additional information or comments about the intended target device or production condition. This key is required if "OutputConditionIdentifier" does not specify a standard production condition; it is optional otherwise. If present, the value must be a CFString.

"DestOutputProfile" - An ICC profile stream defined the transformation from the PDF document's source colors to output device colorants. This key is required if "OutputConditionIdentifier" does not specify a standard production condition; it is optional otherwise. If present, the value must be a ICC-based CGColorSpaceMBS.

NewCFStringMBS("kCGPDFContextOutputIntents")
The document's output intents. Optional; if present, the value must be a CFArrayMBS containing one or more CFDictionaryMBSs. The array is added to the PDF document in the /OutputIntents entry in the PDF file's document catalog. Each dictionary in the array must be of form specified above for the "kCGPDFContextOutputIntent" key, except that only the first dictionary in the array is required to contain the "S" key with a value of "GTS_PDFX". If both the "kCGPDFContextOutputIntent" and "kCGPDFContextOutputIntents" keys are specified, the former will be ignored.

More keys in CGPDFContext.h coming with Xcode.

Feedback, Comments & Corrections

Folderitem.OpenAsCGPDFDocumentMBS as CGPDFDocumentMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 2.7 Yes No No Yes, macOS only No
Function: Opens a PDF document.
Notes:
RB 4.5 should do this perfectly, but older RB versions may have problems with longer file names.
Requires Mac OS X to work.

Some examples which use this method:

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins