function close()
 {
     $this->_show_watermark();
     pdf_end_page($this->pdf);
     pdf_close($this->pdf);
     pdf_delete($this->pdf);
 }
Exemplo n.º 2
0
 function close()
 {
     pdf_end_page($this->pdf);
     pdf_close($this->pdf);
     pdf_delete($this->pdf);
 }
Exemplo n.º 3
0
 /**
  * Output the result of the canvas
  *
  * @param array $param Parameter array
  * @abstract
  */
 function save($param = false)
 {
     parent::save($param);
     pdf_end_page($this->_pdf);
     pdf_close($this->_pdf);
     $buf = pdf_get_buffer($this->_pdf);
     $len = strlen($buf);
     $fp = @fopen($param['filename'], 'wb');
     if ($fp) {
         fwrite($fp, $buf, strlen($buf));
         fclose($fp);
     }
     pdf_delete($this->_pdf);
 }
Exemplo n.º 4
0
pdf_setrgbcolor($pdf, 1.0, 0.0, 0.0);
pdf_setlinewidth($pdf, 2);
pdf_save($pdf);
pdf_rotate($pdf, -(($ltime['seconds'] - 15.0) * 6.0));
pdf_moveto($pdf, -$radius / 5, 0.0);
pdf_lineto($pdf, $radius, 0.0);
pdf_stroke($pdf);
pdf_restore($pdf);
/* draw little circle at center */
pdf_circle($pdf, 0, 0, $radius / 30);
pdf_fill($pdf);
pdf_restore($pdf);
/* DONE */
pdf_end_page($pdf);
pdf_close($pdf);
pdf_delete($pdf);
// hides "Generating ..." message:
echo "<script language='JavaScript'>document.getElementById('loading').style.display = 'none';</script>";
if (!file_exists($file)) {
    ?>
    <h2 style="color: red">Error occured: file <?php 
    echo $file;
    ?>
 does not exist!</h2>
<?php 
}
?>
    It is exactly <?php 
echo $stime;
?>
.
Exemplo n.º 5
0
 function writeToStream($stream)
 {
     pdf_end_page($this->pdf);
     pdf_close($this->pdf);
     $buf = pdf_get_buffer($this->pdf);
     fwrite($stream, $buf);
     pdf_delete($this->pdf);
 }
Exemplo n.º 6
0
 function finish()
 {
     pdf_close($this->pdf);
     pdf_delete($this->pdf);
 }
Exemplo n.º 7
0
function carl_merge_pdfs_pdflib($pdffiles, $titles = array(), $metadata = array(), $metadata_encoding = 'UTF-8')
{
    if (gettype($pdffiles) != 'array') {
        trigger_error('$pdffiles must be an array');
        return false;
    }
    if (!function_exists('PDF_new')) {
        trigger_error('You must have PDFlib installed in order to run carl_merge_pdfs()');
        return false;
    }
    if (empty($pdffiles)) {
        return NULL;
    }
    $i = 0;
    $indoc = 0;
    $pdfver = '1.0';
    $maxpdfver = '1.0';
    $p = PDF_new();
    if (defined('PDFLIB_LICENSE_KEY_FILE')) {
        PDF_set_parameter($p, 'licensefile', PDFLIB_LICENSE_KEY_FILE);
    } else {
        trigger_error('Please define the constant PDFLIB_LICENSE_KEY_FILE with the filesystem location of your PDFlib license keys.');
    }
    /* This means we must check return values of load_font() etc. */
    //PDF_set_parameter($p, 'errorpolicy', 'return');
    /* -----------------------------------------------------------------
     * Loop over all input documents to retrieve the highest PDF version
     * used
     * -----------------------------------------------------------------
     */
    foreach ($pdffiles as $pdffile) {
        /* Open the input PDF */
        if (function_exists('PDF_open_pdi_document')) {
            $indoc = PDF_open_pdi_document($p, $pdffile, '');
        } else {
            $indoc = PDF_open_pdi($p, $pdffile, '', 0);
        }
        // pre-pecl 2.1
        if ($indoc < 1) {
            trigger_error('Error: ' . PDF_get_errmsg($p));
            continue;
        }
        /* Retrieve the PDF version of the current document. If it is higher 
         * than the maximum version retrieved until now make it to be the
         * maximum version.
         */
        if (function_exists('PDF_pcos_get_number')) {
            $pdfver = PDF_pcos_get_number($p, $indoc, 'pdfversion') / 10;
        } else {
            $pdfver = PDF_get_pdi_value($p, 'version', $indoc, 0, 0) / 10;
        }
        if ($pdfver > $maxpdfver) {
            $maxpdfver = $pdfver;
        }
        /* Close the input document.
         * Depending on the number of PDFs and memory strategy, PDI handles
         * to all documents could also be kept open between the first and
         * second run (requires more memory, but runs faster). We close all
         * PDFs after checking the version number, and reopen them in the
         * second loop (requires less memory, but is slower).
         */
        if (function_exists('PDF_close_pdi_document')) {
            PDF_close_pdi_document($p, $indoc);
        } else {
            PDF_close_pdi($p, $indoc);
        }
        // pre-pecl 2.1
    }
    /* ---------------------------------------------------------------
     * Open the output document with the maximum PDF version retrieved
     * --------------------------------------------------------------- 
     */
    if ($maxpdfver > '1.0') {
        $optlist = 'compatibility=' . $maxpdfver;
    } else {
        $optlist = '';
    }
    if (PDF_begin_document($p, '', $optlist) == -1) {
        trigger_error('Error: ' . PDF_get_errmsg($p));
    }
    foreach ($metadata as $key => $value) {
        PDF_set_info($p, $key, $value);
    }
    //PDF_set_info($p, 'Creator', 'Test Creator');
    //PDF_set_info($p, 'Title', $title . ' $Revision: 1.1 $');
    //echo '4 ';
    /* --------------------------------------------------------------------
     * Loop over all input documents to merge them into the output document       * used
     * --------------------------------------------------------------------
     */
    foreach ($pdffiles as $pdffile) {
        $endpage = $pageno = $page = 0;
        /* Open the input PDF */
        if (function_exists('PDF_open_pdi_document')) {
            $indoc = PDF_open_pdi_document($p, $pdffile, '');
        } else {
            $indoc = PDF_open_pdi($p, $pdffile, '', 0);
        }
        // pre-pecl 2.1
        if ($indoc < 1) {
            trigger_error('Error: ' . PDF_get_errmsg($p));
            continue;
        }
        if (function_exists('PDF_pcos_get_number')) {
            $endpage = (int) PDF_pcos_get_number($p, $indoc, '/Root/Pages/Count');
        } else {
            $endpage = (int) PDF_get_pdi_value($p, '/Root/Pages/Count', $indoc, 0, 0);
        }
        // pre-pecl 2.1
        /* Loop over all pages of the input document */
        for ($pageno = 1; $pageno <= $endpage; $pageno++) {
            $page = PDF_open_pdi_page($p, $indoc, $pageno, '');
            if ($page == 0) {
                trigger_error('Error: ' . PDF_get_errmsg($p));
                continue;
            }
            /* Dummy page size; will be adjusted later */
            PDF_begin_page_ext($p, 10, 10, '');
            /* Create a bookmark with the file name */
            if ($pageno == 1) {
                if (isset($titles[$pdffile])) {
                    $bookmark = pack('H*', 'feff') . mb_convert_encoding($titles[$pdffile], 'UTF-16', $metadata_encoding);
                } else {
                    $bookmark = pack('H*', 'feff') . mb_convert_encoding($pdffile, 'UTF-16', $metadata_encoding);
                }
                /* if(isset($titles[$pdffile]))
                				$bookmark = $titles[$pdffile];
                			else
                				$bookmark = $pdffile; */
                PDF_create_bookmark($p, $bookmark, '');
            }
            /* Place the imported page on the output page, and
             * adjust the page size
             */
            PDF_fit_pdi_page($p, $page, 0, 0, 'adjustpage');
            PDF_close_pdi_page($p, $page);
            PDF_end_page_ext($p, '');
        }
        /* Close the input document */
        if (function_exists('PDF_close_pdi_document')) {
            PDF_close_pdi_document($p, $indoc);
        } else {
            PDF_close_pdi($p, $indoc);
        }
        // pre-pecl 2.1
    }
    PDF_end_document($p, '');
    $buffer = PDF_get_buffer($p);
    pdf_delete($p);
    return $buffer;
}