Beispiel #1
9
 /**
  * Parse PDF content
  *
  * @param string $content
  *
  * @return Document
  */
 public function parseContent($content)
 {
     // Create structure using TCPDF Parser.
     ob_start();
     @($parser = new \TCPDF_PARSER(ltrim($content)));
     list($xref, $data) = $parser->getParsedData();
     unset($parser);
     ob_end_clean();
     if (isset($xref['trailer']['encrypt'])) {
         throw new \Exception('Secured pdf file are currently not supported.');
     }
     if (empty($data)) {
         throw new \Exception('Object list not found. Possible secured file.');
     }
     // Create destination object.
     $document = new Document();
     $this->objects = array();
     foreach ($data as $id => $structure) {
         $this->parseObject($id, $structure, $document);
         unset($data[$id]);
     }
     $document->setTrailer($this->parseTrailer($xref['trailer'], $document));
     $document->setObjects($this->objects);
     return $document;
 }
Beispiel #2
1
    /**
     * Import an existing PDF document
     * @param $filename (string) Filename of the PDF document to import.
     * @return true in case of success, false otherwise
     * @public
     * @since 1.0.000 (2011-05-24)
     */
    public function importPDF($filename)
    {
        // load document
        $rawdata = file_get_contents($filename);
        if ($rawdata === false) {
            $this->Error('Unable to get the content of the file: ' . $filename);
        }
        // configuration parameters for parser
        $cfg = array(
            'die_for_errors' => false,
            'ignore_filter_decoding_errors' => true,
            'ignore_missing_filter_decoders' => true,
        );
        try {
            // parse PDF data
            $pdf = new TCPDF_PARSER($rawdata, $cfg);
        } catch (Exception $e) {
            die($e->getMessage());
        }
        // get the parsed data
        $data = $pdf->getParsedData();
        // release some memory
        unset($rawdata);

        // ...


        print_r($data); // DEBUG


        unset($pdf);
    }
 /**
  * Import an existing PDF document
  * @param $filename (string) Filename of the PDF document to import.
  * @return true in case of success, false otherwise
  * @public
  * @since 1.0.000 (2011-05-24)
  */
 public function importPDF($filename)
 {
     // load document
     $rawdata = file_get_contents($filename);
     if ($rawdata === false) {
         $this->Error('Unable to get the content of the file: ' . $filename);
     }
     // parse PDF data
     $pdf = new TCPDF_PARSER($rawdata);
     $data = $pdf->getParsedData();
     // release some memory
     unset($rawdata);
     // ...
     print_r($data);
     // DEBUG
     unset($pdf);
 }
Beispiel #4
0
 /**
  * Parse PDF content
  *
  * @param string $content
  *
  * @return Document
  */
 public function parseContent($content)
 {
     // Create structure using TCPDF Parser.
     $parser = new \TCPDF_PARSER($content);
     list($xref, $data) = $parser->getParsedData();
     if (isset($xref['trailer']['encrypt'])) {
         throw new \Exception('Secured pdf file are currently not supported.');
     }
     // Create destination object.
     $document = new Document();
     $this->objects = array();
     foreach ($data as $id => $structure) {
         $this->parseObject($id, $structure, $document);
     }
     $document->setTrailer($this->parseTrailer($xref['trailer'], $document));
     $document->setObjects($this->objects);
     return $document;
 }