Platforms to show: All Mac Windows Linux Cross-Platform

Back to FolderItem class.

FolderItem.NewCGPDFDocumentWithInfoMBS(MediaBox as CGRectMBS, info as object) 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 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

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.

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


The biggest plugin in space...