Poprosim o radu, vytvaram php script ktorym chcem vytvorit pdf document, chcem aby obrazok ktory upoadnem aby sa vlozil do pdf ale vypisuje mi tuto chybu
uploads/graf.jpg
Fatal error: Uncaught exception 'PDFlibException' with message 'Handle parameter 'image' has bad value 0' in X:\www\createpdf.php:15 Stack trace: #0 X:\www\createpdf.php(15): pdf_place_image(Resource id #2, 0, 28, 324, 2) #1 {main} thrown in X:\www\createpdf.php on line 15
<?php
$uploaddir = 'uploads/'; // Relative path under webroot
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { //FILE
echo $uploadfile;
$mypdf = PDF_new();
PDF_open_file($mypdf, "");
PDF_begin_page($mypdf, 595, 842);
$myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
PDF_setfont($mypdf, $myfont, 12);
$myimage = PDF_open_image_file($mypdf, "jpeg", $uploadfile, "page", 1 );
pdf_place_image($mypdf, $myimage, 28, 324, 2);
pdf_close_image($mypdf, $myimage);
PDF_moveto($mypdf, 0, 735);
PDF_lineto($mypdf, 575, 760);
PDF_stroke($mypdf);
PDF_moveto($mypdf, 20, 55);
PDF_lineto($mypdf, 575, 55);
PDF_stroke($mypdf);
PDF_show_xy($mypdf, "A sample document.", 50, 40);
PDF_end_page($mypdf);
PDF_close($mypdf);
$mybuf = PDF_get_buffer($mypdf);
$mylen = strlen($mybuf);
header("Content-type: application/pdf");
header("Content-Length: $mylen");
header("Content-Disposition: inline; filename=gen03.pdf");
print $mybuf;
PDF_delete($mypdf);
}
else {
echo "File uploading failed.\n";
}
?>