PTElementWriter
@interface PTElementWriter : NSObject
ElementWriter can be used to assemble and write new content to a page, Form XObject, Type3 Glyph stream, pattern stream, or any other content stream.
-
Undocumented
Declaration
Objective-C
- (void)WriterBeginWithPage: (PTPage*)page placement: (PTWriteMode)placement page_coord_sys: (BOOL)page_coord_sys compress: (BOOL)compress resources: (PTObj*)resources;
Swift
func writerBegin(with page: PTPage!, placement: PTWriteMode, page_coord_sys: Bool, compress: Bool, resources: PTObj!)
-
Begin writing to the given page.
By default, new content will be appended to the page, as foreground graphics. It is possible to add new page content as background graphics by setting the second parameter in begin method to ‘true’ (e.g. writer.Begin(page, true)).
Declaration
Objective-C
- (void)Begin:(PTPage *)page placement:(PTWriteMode)placement page_coord_sys:(BOOL)page_coord_sys compress:(BOOL)compress;
Swift
func begin(_ page: PTPage!, placement: PTWriteMode, page_coord_sys: Bool, compress: Bool)
Parameters
page
The page to write content.
placement
An optional flag indicating whether the new content should be added as a foreground or background layer to the existing page. By default, the new content will appear on top of the existing graphics.
page_coord_sys
An optional flag used to select the target coordinate system if true (default), the coordinates are relative to the lower-left corner of the page, otherwise the coordinates are defined in PDF user coordinate system (which may, or may not coincide with the page coordinates).
compress
An optional flag indicating whether the page content stream should be compressed. This may be useful for debugging content streams. Also some applications need to do a clear text search on strings in the PDF files. By default, all content streams are compressed.
resources
the resource dictionary in which to store resources for the final page. By default, a new resource dictionary will be created.
-
A utility function that surrounds the given Element with a graphics state Save/Restore Element (i.e. in PDF content stream represented as ‘q element Q’).
The function is equivalent to calling WriteElement three times: WriteElement(eSave); WriteElement(element); WriteElement(eRestore);
where eSave is ‘e_group_begin’ and eRestore is ‘e_group_end’ Element
The function is useful when XObjects such as Images and Forms are drawn on the page.
Declaration
Objective-C
- (void)WritePlacedElement:(PTElement *)element;
Swift
func writePlacedElement(_ element: PTElement!)
Parameters
element
Element object to enact function on.
-
The Flush method flushes all pending Element writing operations. This method is typically only required to be called when intermixing direct content writing (i.e. WriteBuffer/WriteString) with Element writing.
Declaration
Objective-C
- (void)Flush;
Swift
func flush()
-
Writes an arbitrary buffer to the content stream. This function can be used to insert comments, inline-image data, and chunks of arbitrary content to the output stream.
Declaration
Objective-C
- (void)WriteBuffer:(NSData *)data;
Swift
func writeBuffer(_ data: Data!)
-
Writes an arbitrary string to the content stream. Serves the same purpose as WriteBuffer().
Declaration
Objective-C
- (void)WriteString:(NSString *)str;
Swift
func write(_ str: String!)
Parameters
str
String to write to the content stream.
-
Write only the graphics state changes applied to this element and skip writing the element itself. This is especially useful when rewriting page content, but with the intention to skip certain elements.
Declaration
Objective-C
- (void)WriteGStateChanges:(PTElement *)element;
Swift
func writeGStateChanges(_ element: PTElement!)
Parameters
element
The element for which to write graphics state changes.
-
This method is used to initialize ElementWriter state with the state of a given ElementReader. This can be used to avoid incorrectly writing inherited GState attributes.
Declaration
Objective-C
- (void)SetDefaultGState:(PTElementReader *)reader;
Swift
func setDefaultGState(_ reader: PTElementReader!)
Parameters
reader
ElementReader.
-
Undocumented
Declaration
Objective-C
- (instancetype)init;
Swift
init!()