Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
0
 function _presentation(&$presentation)
 {
     global $pres;
     $_SESSION['selected_display_mode'] = get_class($this);
     // In PDF mode we loop through all the slides and make a single
     // big multi-page PDF document.
     $this->page_number = 0;
     $this->pdf = pdf_new();
     if (!empty($pdfResourceFile)) {
         pdf_set_parameter($this->pdf, "resourcefile", $pdfResourceFile);
     }
     pdf_open_file($this->pdf, null);
     pdf_set_info($this->pdf, "Author", isset($presentation->speaker) ? $presentation->speaker : "Anonymous");
     pdf_set_info($this->pdf, "Title", isset($presentation->title) ? $presentation->title : "No Title");
     pdf_set_info($this->pdf, "Creator", "See Author");
     pdf_set_info($this->pdf, "Subject", isset($presentation->topic) ? $presentation->topic : "");
     while (list($this->slideNum, $slide) = each($presentation->slides)) {
         // testing hack
         $slideDir = dirname($this->presentationDir . '/' . $presentation->slides[$this->slideNum]->filename) . '/';
         $fn = $this->presentationDir . '/' . $presentation->slides[$this->slideNum]->filename;
         $fh = fopen($fn, "rb");
         $r =& new XML_Slide($fh);
         $r->setErrorHandling(PEAR_ERROR_DIE, "%s ({$fn})\n");
         $r->parse();
         $this->objs = $r->getObjects();
         $this->my_new_pdf_page($this->pdf, $this->pdf_x, $this->pdf_y, true);
         $this->pdf_cx = $this->pdf_cy = 0;
         // Globals that keep our current x,y position
         while (list($this->coid, $obj) = each($this->objs)) {
             $obj->display();
         }
         $this->my_new_pdf_end_page($this->pdf);
     }
     $this->my_new_pdf_page($this->pdf, $this->pdf_x, $this->pdf_y, true);
     pdf_set_font($this->pdf, $this->pdf_font, -20, 'winansi');
     $fnt = pdf_findfont($this->pdf, $this->pdf_font, 'winansi', 0);
     $dx = pdf_stringwidth($this->pdf, "Index", $fnt, -20);
     $x = (int) ($this->pdf_x / 2 - $dx / 2);
     pdf_set_parameter($this->pdf, "underline", 'true');
     pdf_show_xy($this->pdf, "Index", $x, 60);
     pdf_set_parameter($this->pdf, "underline", 'false');
     $this->pdf_cy = pdf_get_value($this->pdf, "texty", null) + 30;
     $old_cy = $this->pdf_cy;
     pdf_set_font($this->pdf, $this->pdf_font, -12, 'winansi');
     if (is_array($this->page_index)) {
         foreach ($this->page_index as $pn => $ti) {
             if ($ti == 'titlepage') {
                 continue;
             }
             $ti .= '    ';
             while (pdf_stringwidth($this->pdf, $ti, $fnt, -12) < $this->pdf_x - $this->pdf_cx * 2.5 - 140) {
                 $ti .= '.';
             }
             pdf_show_xy($this->pdf, $ti, $this->pdf_cx * 2.5, $this->pdf_cy);
             $dx = pdf_stringwidth($this->pdf, $pn, $fnt, -12);
             pdf_show_xy($this->pdf, $pn, $this->pdf_x - 2.5 * $this->pdf_cx - $dx, $this->pdf_cy);
             $this->pdf_cy += 15;
             if ($this->pdf_cy > $this->pdf_y - 50) {
                 $this->my_new_pdf_end_page($this->pdf);
                 $this->my_new_pdf_page($this->pdf, $this->pdf_x, $this->pdf_y, false);
                 $this->pdf_cy = $old_cy;
                 pdf_set_font($this->pdf, $this->pdf_font, -12, 'winansi');
             }
         }
     }
     $this->my_new_pdf_end_page($this->pdf);
     pdf_close($this->pdf);
     $data = pdf_get_buffer($this->pdf);
     header('Content-type: application/pdf');
     header('Content-disposition: inline; filename=' . $_SESSION['currentPres'] . '.pdf');
     header("Content-length: " . strlen($data));
     echo $data;
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
0
pdf_lineto($pdf, 121, -11);
pdf_moveto($pdf, 0, 121);
pdf_lineto($pdf, 0, 131);
pdf_moveto($pdf, 121, 121);
pdf_lineto($pdf, 121, 131);
pdf_moveto($pdf, -1, 0);
pdf_lineto($pdf, -11, 0);
pdf_moveto($pdf, -1, 120);
pdf_lineto($pdf, -11, 120);
pdf_moveto($pdf, 122, 0);
pdf_lineto($pdf, 132, 0);
pdf_moveto($pdf, 122, 120);
pdf_lineto($pdf, 132, 120);
pdf_stroke($pdf);
if ($bitmap['front_resolution'] >= $cfg['image_front_cover_treshold']) {
    $pdfdfimage = pdf_load_image($pdf, 'auto', $cfg['media_dir'] . $bitmap['image_front'], '');
    pdf_fit_image($pdf, $pdfdfimage, 0, 0, 'boxsize {121 120} position {50 50} fitmethod slice');
    $hash_data .= '-' . filesize($cfg['media_dir'] . $bitmap['image_front']) . '-' . filemtime($cfg['media_dir'] . $bitmap['image_front']);
}
//  +------------------------------------------------------------------------+
//  | Close and download PDF                                                 |
//  +------------------------------------------------------------------------+
pdf_end_page($pdf);
pdf_close($pdf);
$data = pdf_get_buffer($pdf);
pdf_delete($pdf);
$filename = $album['artist'] . ' - ' . $album['album'] . '.pdf';
$filename = downloadFilename($filename);
$etag = '"' . md5($hash_data) . '"';
streamData($data, 'application/pdf', 'inline', $filename, $etag);
updateCounter($album_id, NJB_COUNTER_COVER);
Ejemplo n.º 5
0
                $pdfdfimage = pdf_open_image_file($pdf, 'png', $node->getMainArt(), '', 0);
            }
            if ($extension == 'gif') {
                $pdfdfimage = pdf_open_image_file($pdf, 'gif', $node->getMainArt(), '', 0);
            }
            $sx = 121 / pdf_get_value($pdf, 'imagewidth', $pdfdfimage);
            $sy = 120 / pdf_get_value($pdf, 'imageheight', $pdfdfimage);
            pdf_scale($pdf, $sx, $sy);
            pdf_place_image($pdf, $pdfdfimage, 0, 0, 1);
        }
        //  +---------------------------------------------------------------------------+
        //  | Close PDF                                                                 |
        //  +---------------------------------------------------------------------------+
        pdf_end_page($pdf);
        pdf_close($pdf);
        $buffer = pdf_get_buffer($pdf);
        $file = $artist . ' - ' . $album . '.pdf';
        header('Content-Type: application/force-download');
        header('Content-Transfer-Encoding: binary');
        header('Content-Disposition: attachment; filename="' . $file . '"');
        //rawurlencode not needed for header
        echo $buffer;
        pdf_delete($pdf);
        exit;
    }
}
$this->displayPageTop("", word("Create PDF Cover"));
$this->openBlock();
$dlarr = array();
$dlarr['action'] = "popup";
$dlarr['ptype'] = "pdfcover";
Ejemplo n.º 6
0
        if (is_array($a) && @count($a)) {
            foreach ($a as $i) {
                $attch[] = array('id' => $i[0], 'name' => $i[1], 'nd' => $i[3]);
            }
            $fpdf->add_attacments($attch);
        }
    }
    /* handle polls */
    if ($o->poll_name && $o->poll_cache) {
        $pc = @unserialize($o->poll_cache);
        if (is_array($pc) && count($pc)) {
            reverse_fmt($o->poll_name);
            foreach ($pc as $opt) {
                $opt[0] = strip_tags(post_to_smiley($opt[0], $re));
                reverse_fmt($opt[0]);
                $votes[] = array('name' => $opt[0], 'votes' => $opt[1]);
            }
            $fpdf->add_poll($o->poll_name, $votes, $o->total_votes);
        }
    }
    $fpdf->end_message();
} while ($o = db_rowobj($c));
un_register_fps();
$fpdf->end_page();
pdf_close($fpdf->pdf);
$pdf = pdf_get_buffer($fpdf->pdf);
header('Content-type: application/pdf');
header('Content-length: ' . strlen($pdf));
header('Content-disposition: inline; filename=FUDforum' . date('Ymd') . '.pdf');
echo $pdf;
pdf_delete($fpdf->pdf);