PHP/PDF/pdf new
Adding Images
$pdf = pdf_new( );
pdf_open_file($pdf, "/path/to/your.pdf");
pdf_begin_page($pdf, 600, 800);
$testimage = pdf_open_image_file($pdf, "jpeg", "myimage.jpg");
pdf_place_image($pdf, $testimage, 0, 0, 0.5);
pdf_end_page($pdf);
pdf_close($pdf);
pdf_delete($pdf);
Generating a PDF document
<?
$fontsize = 72; // 1 inch high letters
$page_height = 612; // 8.5 inch high page
$page_width = 792; // 11 inch wide page
if (strlen(trim($_GET["message"]))) {
$message = trim($_GET["message"]);
} else {
$message = "Generate a PDF!";
}
$pdf = pdf_new();
pdf_open_file($pdf, "");
pdf_begin_page($pdf, $page_width, $page_height);
$font = pdf_findfont($pdf, "Helvetica", "winansi", 0);
pdf_setfont($pdf, $font, $fontsize);
pdf_show_boxed($pdf, $message, 0, ($page_height-$fontsize)/2,$page_width, $fontsize, "center");
pdf_end_page($pdf);
pdf_close($pdf);
$pdf_doc = pdf_get_buffer($pdf);
pdf_delete($pdf);
header("Content-Type: application/pdf");
header("Content-Length: " . strlen($pdf_doc));
print $pdf_doc;
?>