Manuals

 

SetaPDF_Merger::extract()

Description

class SetaPDF_Merger extends SetaPDF {
mixed extract ( mixed $pages[, mixed $bookmark=null[, string $fileName='doc.pdf'[, string $dest='F'[, boolean $stream=false]]]] ) }

This method gives you the possibility to use the API for extracting a single page or page range of an existing document.

As the method doesn't closes any opened parser you should call the cleanUp()-method when you're done.

Parameters

$pages

In this parameter you can define the page(s) which should be read from the given document.

A single page can be defined as an integer value. A range can be defined as an array with 2 values:

array($startPage, $endPage)

$bookmark

This parameter defines the handling of a bookmark entry for this page range/document. There are a few possibilities for this parameter:

1. Pass null or omit the parameter will tell the API to resolve the title text for the bookmark entry from the meta data of the merged document.

2. Pass a simple string to this parameter, which will become the title text in the bookmark entry.

3. Pass false to prevent a bookmark creation for this page range/document.

4. Pass an array with the following structure:

array(
   'title' => (string) "The bookmark title"
   'color' => array(red, green, blue) // Text color
   'format' => SETAPDF_M_BOOKMARK_FORMAT_ITALIC | SETAPDF_M_BOOKMARK_FORMAT_BOLD,
   'parent' => an Id of a parent node returned by addFile,
   'copyBookmarks' => SETAPDF_M_COPY_BOOKMARKS_AS_CHILD || SETAPDF_M_COPY_BOOKMARKS_TO_SAME_LEVEL
)

All keys are optional and are described here with examples and detailed description.

$fileName

A valid path and filename for the new document if the dest-parameter is set to "F". Otherwise the name of the new PDF document.

$dest

Defines how the merged documents are handled:

  • "F" saves the file to the file system
  • "D" the file will be send to the client with a download dialogue
  • "I" the file will be displayed in the client's browser window.

$stream

This parameter is only used if dest is set to "D" or "I". If it is set to true, the document will be sent immediately as soon as the first content bytes are available. In this case the length-header will not be sent. If this parameter is set to false, the whole document is held in memory until it is completely assembled.

The streaming facility is very effective, because the client does not become aware of any script processing time.

Return Value

True - if everything works as expected - an SetaPDF_Error object if an error occurs.

Version

As of Version 1.3