I am trying to allow users to download PDF files that are dynamically generated that include PHP scripting as well as explanation. I have searched php.net extensively and I think PDF functions are very poorly documented since I can't understand them. Anyone know of any PHP/PDF tutorials? Can anyone tell me how I'm doing?
<?php
if (!empty($filename)) {
$len = filesize($filename);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=$filename");
readfile($filename);
}
else {
$this_pagetitle="Scripts in PDF format";
require("../config.php");
include("../header.php");
$pdf = pdf_new();
pdf_open_file($pdf, "$script.pdf");
pdf_set_info($pdf, "Author", "Adam Scheinberg");
pdf_set_info($pdf, "Title", "$scriptname");
pdf_set_info($pdf, "Creator", "see Author");
pdf_set_info($pdf, "Subject", "$scriptname");
pdf_begin_page($pdf, 595, 842);
pdf_add_outline($pdf, "Page 1");
pdf_set_font($pdf, "Times-Roman", 30, "host");
pdf_set_value($pdf, "textrendering", 1);
pdf_show_xy($pdf, "Times Roman outlined", 50, 750);
pdf_moveto($pdf, 50, 740);
pdf_lineto($pdf, 330, 740);
pdf_stroke($pdf);
$pdfimage = pdf_open_image_file($pdf, "png","pdfheader.png");
pdf_place_image($pdf, $pdfimage, 10, 10, 0.6);
pdf_show($script); //does this write?
pdf_end_page($pdf);
pdf_close($pdf);
//pdf_delete($pdf);
echo "<A HREF=pdf.php?filename=function.pdf>script library</A>";
}
?>