Next Page > Hide TOC

CGPDFScanner Reference

Derived from
None
Framework
ApplicationServices/ApplicationServices.h
Companion guide
Declared in
CGPDFScanner.h

Overview

The CGPDFScannerRef opaque type is used to parse a PDF content stream. You can set up the PDF scanner object to invoke callbacks when it encounters specific PDF operators in the stream.

This opaque type is not derived from CFType and therefore there are no functions for retaining and releasing it.

Functions by Task

Creating a PDF Scanner Object

Retaining and Releasing PDF Scanner Objects

Parsing Content

Getting PDF Objects from the Scanner Stack

Functions

CGPDFScannerCreate

Creates a CGPDFScanner object.

CGPDFScannerRef CGPDFScannerCreate (
   CGPDFContentStreamRef cs,
   CGPDFOperatorTableRef table,
   void *info
);

Parameters
cs

A CGPDFContentStream object. (See CGPDFContentStream Reference.)

table

A CGPDFOperatorTable object that contains callbacks for the PDF operators you want to handle.

info

A pointer to data you want passed to your CGPDFOperatorTable callback function. (See CGPDFOperatorTable Reference.)

Return Value

A CGPDFScanner object. You are responsible for releasing this object by calling the function CGPDFScannerRelease.

Discussion

When you want to parse the contents of the PDF stream, call the function CGPDFScannerScan.

Availability
Declared In
CGPDFScanner.h

CGPDFScannerGetContentStream

Returns the content stream associated with a CGPDFScanner object.

CGPDFContentStreamRef CGPDFScannerGetContentStream (
   CGPDFScannerRef scanner
);

Parameters
scanner

The scanner object whose content stream you want to obtain.

Return Value

Return the content stream associated with scanner.

Availability
Declared In
CGPDFScanner.h

CGPDFScannerPopArray

Retrieves an array object from the scanner stack.

bool CGPDFScannerPopArray (
   CGPDFScannerRef scanner,
   CGPDFArrayRef *value
);

Parameters
scanner

A valid scanner object.

value

On output, points to the CGPDFArray object popped from the scanner stack.

Return Value

Returns true if value is retrieved successfully; false otherwise.

Availability
Declared In
CGPDFScanner.h

CGPDFScannerPopBoolean

Retrieves a Boolean object from the scanner stack.

bool CGPDFScannerPopBoolean (
   CGPDFScannerRef scanner,
   CGPDFBoolean *value
);

Parameters
scanner

A valid scanner object.

value

On output, points to the CGPDFBoolean object popped from the scanner stack.

Return Value

Returns true if value is retrieved successfully; false otherwise.

Availability
Declared In
CGPDFScanner.h

CGPDFScannerPopDictionary

Retrieves a PDF dictionary object from the scanner stack.

bool CGPDFScannerPopDictionary (
   CGPDFScannerRef scanner,
   CGPDFDictionaryRef *value
);

Parameters
scanner

A valid scanner object.

value

On output, points to the CGPDFDictionary object popped from the scanner stack.

Return Value

Returns true if value is retrieved successfully; false otherwise.

Availability
Declared In
CGPDFScanner.h

CGPDFScannerPopInteger

Retrieves an integer object from the scanner stack.

bool CGPDFScannerPopInteger (
   CGPDFScannerRef scanner,
   CGPDFInteger *value
);

Parameters
scanner

A valid scanner object.

value

On output, points to the CGPDFInteger object popped from the scanner stack.

Return Value

Returns true if value is retrieved successfully; false otherwise.

Availability
Declared In
CGPDFScanner.h

CGPDFScannerPopName

Retrieves a character string from the scanner stack.

bool CGPDFScannerPopName (
   CGPDFScannerRef scanner,
   const char **value
);

Parameters
scanner

A valid scanner object.

value

On output, points to the character string popped from the scanner stack.

Return Value

Returns true if value is retrieved successfully; false otherwise.

Availability
Declared In
CGPDFScanner.h

CGPDFScannerPopNumber

Retrieves a real value object from the scanner stack.

bool CGPDFScannerPopNumber (
   CGPDFScannerRef scanner,
   CGPDFReal *value
);

Parameters
scanner

A valid scanner object.

value

On output, points to the CGPDFReal object popped from the scanner stack.

Return Value

Returns true if value is retrieved successfully; false otherwise.

Discussion

The number retrieved from the scanner can be a real value or an integer value. However, the result is always converted to a CGPDFReal data type.

Availability
Declared In
CGPDFScanner.h

CGPDFScannerPopObject

Retrieves an object from the scanner stack.

bool CGPDFScannerPopObject (
   CGPDFScannerRef scanner,
   CGPDFObjectRef *value
);

Parameters
scanner

A valid scanner object.

value

On output, points to the object popped from the scanner stack.

Return Value

Returns true if value is retrieved successfully; false otherwise.

Availability
Declared In
CGPDFScanner.h

CGPDFScannerPopStream

Retrieves a PDF stream object from the scanner stack.

bool CGPDFScannerPopStream (
   CGPDFScannerRef scanner,
   CGPDFStreamRef *value
);

Parameters
scanner

A valid scanner object.

value

On output, points to the CGPDFStream object popped from the scanner stack.

Return Value

Returns true if value is retrieved successfully; false otherwise.

Availability
Declared In
CGPDFScanner.h

CGPDFScannerPopString

Retrieves a string object from the scanner stack.

bool CGPDFScannerPopString (
   CGPDFScannerRef scanner,
   CGPDFStringRef *value
);

Parameters
scanner

A valid scanner object.

value

On output, points to the CGPDFString object popped from the scanner stack.

Return Value

Returns true if value is retrieved successfully; false otherwise.

Availability
Declared In
CGPDFScanner.h

CGPDFScannerRelease

Decrements the retain count of a scanner object.

void CGPDFScannerRelease (
   CGPDFScannerRef scanner
);

Parameters
scanner

The scanner object to release.

Availability
Declared In
CGPDFScanner.h

CGPDFScannerRetain

Increments the retain count of a scanner object.

CGPDFScannerRef CGPDFScannerRetain (
   CGPDFScannerRef scanner
);

Parameters
scanner

The scanner object to retain.

Return Value

The same scanner object passed to the function in the scanner parameter.

Availability
Declared In
CGPDFScanner.h

CGPDFScannerScan

Parses the content stream of a CGPDFScanner object.

bool CGPDFScannerScan (
   CGPDFScannerRef scanner
);

Parameters
scanner

The scanner object whose content stream you want to parse.

Return Value

Returns true if the entire stream is parsed successfully; false if parsing fails (for example, if the stream data is corrupted).

Discussion

The function CGPDFScannerScan parses the PDF content stream associated with the scanner. Each time Quartz parses a PDF operator for which you register a callback, Quartz invokes your callback.

Availability
Declared In
CGPDFScanner.h

Data Types

CGPDFScannerRef

An opaque type used to parse a PDF content stream.

typedef struct CGPDFScanner *CGPDFScannerRef;

Availability
Declared In
CGPDFScanner.h

Next Page > Hide TOC


© 2004, 2008 Apple Inc. All Rights Reserved. (Last updated: 2008-10-15)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.