/** * 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(""); }