/** * __construct populates standard encoding arrays * * @param resource $fh - file handle to the PDF file * * @return N/A */ public function __construct($fh) { parent::__construct(); $this->fh = $fh; if ($this->debugLevel > self::DEBUG_HIDE_DECODING) { echo "Created decoder<br />\n"; } $this->populateEncoding(); }
/** * __construct sets up the page attributes and converts some key PDF objects * to PHP objects * * @param resource $fh - the file handle created by the PDFreader class * @param array $Xrefs - the XRef table extracted by the PDFreader class * @param object $PDFdecoder - the PDFdecoder from the PDFreader class * @param string $reference - the PDF reference to this object * @param array $Annots - array of references to annotation dictionaries * * @return N/A */ public function __construct($fh, $Xrefs, $PDFdecoder, $reference, $Annots) { parent::__construct(); $this->fh = $fh; $this->Xrefs = $Xrefs; $this->PDFdecoder = $PDFdecoder; if (!isset($reference)) { throw new PDFexception('Form creation error: Invalid form reference.'); } if ($this->debugLevel > self::DEBUG_OFF) { echo "<strong><u>CREATING FORM {$reference}</u></strong><br />\n"; } $formObj = $this->extractObject($reference); $formDictionary = $this->extractDictionary($formObj); //Set required PDF attributes if (!isset($formDictionary['Fields'])) { throw new PDFexception('Form creation error: No form fields found.'); } $this->Fields = $formDictionary['Fields']; //Set optional PDF attributes if (isset($formDictionary['NeedAppearances'])) { $this->NeedAppearances = $formDictionary['NeedAppearances'] == true; } if (isset($formDictionary['SigFlags'])) { $this->SigFlags = $this->extractSigFlags($formDictionary['SigFlags']); } if (isset($formDictionary['CO'])) { $this->CO = $formDictionary['CO']; } if (isset($formDictionary['DR'])) { $this->DR = $formDictionary['DR']; } if (isset($formDictionary['DA'])) { $this->DA = $formDictionary['DA']; } if (isset($formDictionary['Q'])) { $this->Q = $formDictionary['Q']; } if (isset($formDictionary['XFA'])) { $this->XFA = $this->extractXFA($formDictionary['XFA']); } //Set PHP attributes if (isset($reference)) { $this->reference = $reference; } if (isset($Annots)) { $this->Annots = $Annots; } $this->extractFields(); }
/** * __construct accepts a single PDF reference, dereferences it, * parses the dictionary and decodes the text in the content stream * * The combination of a resource dictionary and content stream constitutes * a self-contained entity. PDF spec 7.8.1 * * @param resource $fh - the file handle created by the PDFreader class * @param array $Xrefs - the XRef table extracted by the PDFreader class * @param object $PDFdecoder - the PDFdecoder from the PDFreader class * @param string $reference - a PDF reference to this object like %d %d R * @param string $Resources - the parent page's resource dictionary * * @return N/A */ public function __construct($fh, $Xrefs, $PDFdecoder, $reference, $Resources) { parent::__construct(); $this->fh = $fh; $this->Xrefs = $Xrefs; $this->PDFdecoder = $PDFdecoder; if (!isset($reference)) { throw new PDFexception('Error: Invalid object reference'); } if ($this->debugLevel > self::DEBUG_OFF) { echo "<strong>Creating content stream {$reference}</strong><br />\n"; } $this->reference = $reference; $this->parseResourceDictionary($Resources); $stream = $this->extractStream($reference); $this->parseStreamDictionary($stream['Dictionary']); $this->stream = $stream['Contents']; $this->decodeText(); }
/** * __construct sets up the page attributes and converts some key PDF objects * to PHP objects * * @param resource $fh - the file handle from the PDFreader class * @param array $Xrefs - the XRef table from the PDFreader class * @param object $PDFdecoder - the PDFdecoder instance from the PDFreader class * @param array $pageDictionary - an array of PDF page attributes * @param string $ref - an optional PDF reference to this object * * @return N/A */ public function __construct($fh, $Xrefs, $PDFdecoder, $pageDictionary, $ref) { parent::__construct(); $this->fh = $fh; $this->Xrefs = $Xrefs; $this->PDFdecoder = $PDFdecoder; if ($this->debugLevel > self::DEBUG_OFF) { echo "<strong><u>CREATING PAGE {$ref}</u></strong><br />\n"; } //Set required PDF attributes if (!isset($pageDictionary['Parent'])) { throw new PDFexception('Error: Page parent could not be determined.'); } $this->Parent = $pageDictionary['Parent']; if (!isset($pageDictionary['Resources'])) { throw new PDFexception('Error: Page resources could not be found.'); } $this->Resources = $this->extractResources($pageDictionary['Resources']); if (!isset($pageDictionary['MediaBox'])) { throw new PDFexception('Error: Page MediaBox could not be determined.'); } $this->MediaBox = $pageDictionary['MediaBox']; if (!isset($pageDictionary['Contents'])) { throw new PDFexception('Error: Page contents could not be found.'); } $this->Contents = $pageDictionary['Contents']; //Set optional PDF attributes if (isset($pageDictionary['LastModified'])) { $this->LastModified = $pageDictionary['LastModified']; } if (isset($pageDictionary['CropBox'])) { $this->CropBox = $pageDictionary['CropBox']; } if (isset($pageDictionary['BleedBox'])) { $this->BleedBox = $pageDictionary['BleedBox']; } if (isset($pageDictionary['TrimBox'])) { $this->TrimBox = $pageDictionary['TrimBox']; } if (isset($pageDictionary['ArtBox'])) { $this->ArtBox = $pageDictionary['ArtBox']; } if (isset($pageDictionary['BoxColorInfo'])) { $this->BoxColorInfo = $pageDictionary['BoxColorInfo']; } if (isset($pageDictionary['Rotate'])) { $this->Rotate = $pageDictionary['Rotate']; } if (isset($pageDictionary['Group'])) { $this->Group = $pageDictionary['Group']; } if (isset($pageDictionary['Thumb'])) { $this->Thumb = $pageDictionary['Thumb']; } if (isset($pageDictionary['B'])) { $this->B = $pageDictionary['B']; } if (isset($pageDictionary['Dur'])) { $this->Dur = $pageDictionary['Dur']; } if (isset($pageDictionary['Trans'])) { $this->Trans = $pageDictionary['Trans']; } if (isset($pageDictionary['Annots'])) { $this->Annots = $pageDictionary['Annots']; } if (isset($pageDictionary['AA'])) { $this->AA = $pageDictionary['AA']; } if (isset($pageDictionary['Metadata'])) { $this->Metadata = $pageDictionary['Metadata']; } if (isset($pageDictionary['PieceInfo'])) { $this->PieceInfo = $pageDictionary['PieceInfo']; } if (isset($pageDictionary['StructParents'])) { $this->StructParents = $pageDictionary['StructParents']; } if (isset($pageDictionary['ID'])) { $this->ID = $pageDictionary['ID']; } if (isset($pageDictionary['PZ'])) { $this->PZ = $pageDictionary['PZ']; } if (isset($pageDictionary['SeparationInfo'])) { $this->SeparationInfo = $pageDictionary['SeparationInfo']; } if (isset($pageDictionary['Tabs'])) { $this->Tabs = $pageDictionary['Tabs']; } if (isset($pageDictionary['TemplateInstantiated'])) { $this->TemplateInstantiated = $pageDictionary['TemplateInstantiated']; } if (isset($pageDictionary['PresSteps'])) { $this->PresSteps = $pageDictionary['PresSteps']; } if (isset($pageDictionary['UserUnit'])) { $this->UserUnit = $pageDictionary['UserUnit']; } if (isset($pageDictionary['VP'])) { $this->VP = $pageDictionary['VP']; } //Set PHP attributes if (isset($ref)) { $this->reference = $ref; } $this->extractContents($this->Resources, $this->Contents); }
/** * __construct sets up an HTML page if debugging is enabled */ public function __construct() { parent::__construct(); if ($this->debugLevel > self::DEBUG_OFF) { echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'; echo ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PDFreader Debugger</title> </head> <body>' . "\n"; } $this->trailer = array(); }
/** * __construct sets up the field attributes and converts some key PDF objects * to PHP objects * * @param resource $fh - the file handle created by the PDFreader class * @param array $Xrefs - the XRef table extracted by the PDFreader class * @param object $PDFdecoder - the PDFdecoder from the PDFreader class * @param string $reference - the PDF reference to this object * @param object $parent - an optional form field object that is * the parent of this object * * @return N/A */ public function __construct($fh, $Xrefs, $PDFdecoder, $reference, $parent = null) { parent::__construct(); $this->fh = $fh; $this->Xrefs = $Xrefs; $this->PDFdecoder = $PDFdecoder; if (empty($reference)) { throw new PDFexception('Field creation error: Invalid field reference'); } if ($this->debugLevel > self::DEBUG_OFF) { echo "<strong><u>Creating form field {$reference}</u></strong><br />\n"; } $fieldObj = $this->extractObject($reference); $fieldDictionary = $this->extractDictionary($fieldObj); if ($this->debugLevel > self::DEBUG_OFF) { echo "Default field name {$fieldDictionary['T']}<br />\n"; } //Set required PDF attributes if (!isset($fieldDictionary['FT'])) { if (isset($parent)) { //Field type is inheritable $this->FT = $parent->getFieldType(); } else { if (!isset($fieldDictionary['Kids'])) { //FT may be set on children throw new PDFexception('Field creation error: Field type could not be determined.'); } } } else { $this->FT = $fieldDictionary['FT']; } //Set optional PDF attributes if (isset($parent)) { $this->Parent = $parent; } if (isset($fieldDictionary['Kids'])) { $this->Kids = $fieldDictionary['Kids']; $this->createChildren(); } if (isset($fieldDictionary['T'])) { $this->T = $fieldDictionary['T']; } if (isset($fieldDictionary['TU'])) { $this->TU = $fieldDictionary['TU']; } if (isset($fieldDictionary['TM'])) { $this->TM = $fieldDictionary['TM']; } if (isset($fieldDictionary['Ff'])) { $this->Ff = $this->extractFieldFlags($fieldDictionary['Ff']); } if (isset($fieldDictionary['V'])) { $this->V = $fieldDictionary['V']; } if (isset($fieldDictionary['DV'])) { $this->DV = $fieldDictionary['DV']; } if (isset($fieldDictionary['AA'])) { $this->AA = $fieldDictionary['AA']; } if (isset($fieldDictionary['DA'])) { $this->DA = $fieldDictionary['DA']; } if (isset($fieldDictionary['Q'])) { $this->Q = $fieldDictionary['Q']; } if (isset($fieldDictionary['DS'])) { $this->DS = $fieldDictionary['DS']; } if (isset($fieldDictionary['RV'])) { $this->RV = $fieldDictionary['RV']; } if (isset($fieldDictionary['AP'])) { $this->AP = $fieldDictionary['AP']; } //Set PHP attributes $this->reference = $reference; $this->determineValue(); }