/** * Add all active objects to the current page */ protected function _place_objects() { foreach ($this->_objs as $obj => $props) { $start = $props["start_page"]; $where = $props["where"]; // Place the object on this page if required if ($this->_page_number >= $start && ($this->_page_number % 2 == 0 && $where === "even" || $this->_page_number % 2 == 1 && $where === "odd" || $where === "all")) { $this->_pdf->fit_image($obj, 0, 0, ""); } } }
function image($img_url, $img_type, $x, $y, $w, $h) { $w = (int) $w; $h = (int) $h; if (isset($this->_imgs[$img_url])) { $img = $this->_imgs[$img_url]; } else { $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, ""); } $this->_pdf->fit_image($img, $x, $y + $h, "boxsize=\\{{$w} {$h}} fitmethod=entire"); }
function image($img_url, $x, $y, $w, $h, $resolution = "normal") { $w = (int) $w; $h = (int) $h; $img_type = Cache::detect_type($img_url); if (!isset($this->_imgs[$img_url])) { $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, ""); } $img = $this->_imgs[$img_url]; $y = $this->y($y) - $h; $this->_pdf->fit_image($img, $x, $y, 'boxsize={' . "{$w} {$h}" . '} fitmethod=entire'); }
function image($img_url, $x, $y, $w, $h, $resolution = "normal") { $w = (int) $w; $h = (int) $h; $img_type = Image_Cache::detect_type($img_url, $this->_dompdf->get_http_context()); $img_ext = Image_Cache::type_to_ext($img_type); if (!isset($this->_imgs[$img_url])) { $this->_imgs[$img_url] = $this->_pdf->load_image($img_ext, $img_url, ""); } $img = $this->_imgs[$img_url]; $y = $this->y($y) - $h; $this->_pdf->fit_image($img, $x, $y, 'boxsize={' . "{$w} {$h}" . '} fitmethod=entire'); }
function image($img_url, $x, $y, $w, $h, $resolution = "normal") { $w = (int) $w; $h = (int) $h; $img_type = Image_Cache::detect_type($img_url); $img_ext = Image_Cache::type_to_ext($img_type); if (isset($this->_imgs[$img_url])) { $img = $this->_imgs[$img_url]; } else { $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, ""); } $y = $this->y($y) - $h; $this->_pdf->fit_image($img, $x, $y, "boxsize=\\{{$w} {$h}\\} fitmethod=entire"); }
function image($img_url, $img_type, $x, $y, $w, $h) { $w = (int) $w; $h = (int) $h; $img_type = strtolower($img_type); if ($img_type == "jpg") { $img_type = "jpeg"; } if (isset($this->_imgs[$img_url])) { $img = $this->_imgs[$img_url]; } else { $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, ""); } $y = $this->y($y) - $h; $this->_pdf->fit_image($img, $x, $y, 'boxsize={' . "{$w} {$h}" . '} fitmethod=entire'); }
/** * This function creates a PDF with a title, an image and a comment. * * @param $page_width (The page width in dpi. (inches x 72) ) * @param $page_height (The page height in dpi. (inches x 72) ) * @param $title (The title to insert in the pdf) * @param $comments (The comments to insert in the pdf) * @param $mapImageUrl (The url to the image to insert in the pdf) */ function createPDF($page_width, $page_height, $title, $comments, $mapImageUrl) { $p = new PDFlib(); /* open new PDF file; insert a file name to create the PDF on disk */ if ($p->begin_document($mapImageUrl . ".pdf", "") == 0) { die("Error: " . $p->get_errmsg()); } // These lines should set the PDF properties, but it does not seem to work. $p->set_info("Creator", "Vigilance"); $p->set_info("Author", "Vigilance"); $p->set_info("Title", $title); // Create a new PDF page. $p->begin_page_ext($page_width, $page_height, ""); // Loads the Helvetica font. $font = $p->load_font("Helvetica", "winansi", ""); $p->setfont($font, 20.0); // Displays the title as set by the user // On ne peut pas dire a pdflib de centrer le texte sur la ligne... donc $page_width / 2 - 20; $p->set_text_pos($page_width / 2 - 20, $page_height - 30); $p->show($title); // Adds the image to the PDF. $image = $p->load_image("auto", $mapImageUrl, ""); $p->fit_image($image, 30, 80, ""); $p->close_image($image); // Adds the comments to the PDF. $p->set_text_pos(10, 60); $p->setfont($font, 12.0); $p->continue_text($comments); // Ends the page and the document. $p->end_page_ext(""); $p->end_document(""); }
function generate_document() { $settings = Settings::get($this->user['database'])->toArray(); if (!isset($_POST['link'])) { die; } $host = "http://" . $settings['aws_host_url'] . '/'; if (substr($_POST['link'], 0, 5) == 'EZPRO') { $prefix = "EZPRO"; } else { $prefix = "DTMS"; } // Instantiate S3 Client $S3Client = S3Client::factory(array('key' => $settings['aws_access_key_id'], 'secret' => $settings['aws_secret_access_key'])); switch ($prefix) { case "EZPRO": $year = substr($_POST['link'], 5, 4); $month = substr($_POST['link'], 9, 2); $search = "EZPRO" . $year . $month; $result = $S3Client->listObjects(array('Bucket' => $settings['aws_bucket'], 'MaxKeys' => 1, 'Prefix' => "EZPRO/POD/" . $year . "/" . $month . str_replace($search, '/', $_POST['link']))); break; default: $year = substr($_POST['link'], 5, 4); $month = substr($_POST['link'], 10, 2); $search = "DTMS_" . $year . "_" . $month . "_"; $result = $S3Client->listObjects(array('Bucket' => $settings['aws_bucket'], 'MaxKeys' => 1, 'Prefix' => "DTMS/" . $year . "/" . $month . str_replace($search, '/', $_POST['link']) . ".")); break; } if (isset($result['Contents'])) { $link = $host . $result['Contents'][0]['Key']; } else { die; } echo $link; $data = file_get_contents($link); $pdf = new PDFlib(); $pdf->begin_document("", ""); for ($frame = 1;; $frame++) { $pdf->create_pvf("/tracking/pvf/image", $data, ""); $bol = $pdf->load_image("auto", "/tracking/pvf/image", "page=" . $frame); if ($bol == 0) { break; } $imagewidth = $pdf->get_value("imagewidth", $bol) * 72 / $pdf->get_value("resx", $bol); $imageheight = $pdf->get_value("imageheight", $bol) * 72 / $pdf->get_value("resy", $bol); $pdf->begin_page_ext($imagewidth, $imageheight, ""); $pdf->fit_image($bol, 0, 0, ""); $pdf->end_page_ext(""); $pdf->delete_pvf("/tracking/pvf/image"); } $pdf->end_document(""); $buf = $pdf->get_buffer(); print $buf; }