The code above is not mine, but a sample I found in another forum.
The code I'll include below is mine. I'm sending several files to a PDF. I'm only sending my headers once. As I said before, this code is working in Mozilla based browsers, but not in Internet Explorer:
<?
// Globals...
global $HTTP_GET_VARS;
global $HTTP_HOST;
global $HTTP_REFERER;
global $PHP_SELF;
$url = $HTTP_REFERER;
$prods_local_path = "{local path}/PRODS/";
$prods_http_path = "{web address}/PRODS/";
$prodvar_found = 0;
//Converts the named file/URL to PDF.
function topdf($filenames, $options, $folder) {
$print_filename = $folder."P.PDF";
//Write the content type to the client...
header("Content-Type: application/pdf");
header("Content-Disposition: inline; filename=\"".$print_filename."\"");
flush();
//Standard Files added to PDF
$copyright_file = "{web address}/PDF/copyright.htm";
//Create additional options
$options .= "-t pdf "; //specify output format for document - leave as general pdf
$options .= "--quiet "; //prevents error messages from being sent to stderr
$options .= "--jpeg "; //enables jpeg compression of images
$options .= "--webpage "; //specifies that multiple files comprise a complete web page for printing
$options .= "--continuous "; //allows multiple files to be processed
$options .= "--no-localfiles "; //disables access to local files on system for security
$options .= "--no-compression "; //specifies that Flate compression should not be performed on output files
$options .= "--bodyfont Arial "; //specify default text font used in document body
$options .= "--links "; //specifies that there are to be links in the file
$options .= "--permissions no-copy "; //specify user cannot copy text and images from document
$options .= "--permissions no-modify "; //specify user cannot modify document
$options .= "--permissions print "; //specify user can print document
$options .= "--encryption "; //required with permissions options
//Create Additional Files String
foreach ($filenames as $value) {
if ($value) {
$files_to_process .= "'".$value."' ";
}
}
$files_to_process .= "'$copyright_file' ";
//echo "htmldoc $options $files_to_process";
# Run HTMLDOC to provide the PDF file to the user...
passthru("htmldoc $options $files_to_process");
}
//Locate /PRODS string in url
$prods_pos = strpos($url, '/PRODS');
//Parse out everything before string, including string
$folder = substr($url, $prods_pos + 7);
//Locate slash in folder string
$slash_pos = strpos($folder, '/');
//Parse out everything after slash to create folder
$folder = substr($folder, 0, $slash_pos);
//Check if this is a long-form review
$file_name = $prods_local_path.$folder."/PRODVAR.HTM";
if (file_exists($file_name)) {
$prodvar_found = 1;
//Locate last slash in rekey URL
$slash_pos = strrpos($url, '/');
//Parse out everything before last slash, including slash
$prefix = substr($url, $slash_pos + 1);
//Locate A marker in remaining string
$period_pos = strrpos($prefix, 'A');
//Parse out everything after A marker to create prefix
$prefix = substr($prefix, 0, $period_pos);
//Create array of files present in directory for PDF printing
$i = 1;
$content_file = $prods_local_path.$folder."/".$prefix."A1.htmf";
while (file_exists($content_file)) {
//Create correct file path string
$content_file = $prods_http_path.$folder."/".$prefix."A".$i.".htmf";
//Add file to array
$files_to_pdf[$i] = $content_file;
//Create next file to check for addition to array
$i++;
$content_file = $prods_local_path.$folder."/".$prefix."A".$i.".htmf";
}
//Check if last file had a 'html' extension
if (file_exists($content_file)) {
//Create correct file path string
$content_file = $prods_http_path.$folder."/".$prefix."A".$i.".htmf";
//Add file to array
$files_to_pdf[$i] = $content_file;
}
}
//Process as short form review if not long-form
if (!$prodvar_found) {
//Add files to array
if (file_exists($prods_local_path.$folder."/001.htmf")) {
$files_to_pdf[0] = $prods_http_path.$folder."/001.htmf";
} elseif (file_exists($prods_local_path.$folder."/001.htm")) {
$files_to_pdf[0] = $prods_http_path.$folder."/001.htm";
} else {
}
if (file_exists($prods_local_path.$folder."/002.htmf")) {
$files_to_pdf[1] = $prods_http_path.$folder."/002.htmf";
} elseif (file_exists($prods_local_path.$folder."/002.htm")) {
$files_to_pdf[1] = $prods_http_path.$folder."/002.htm";
} else {
}
}
$options = "";
topdf($files_to_pdf, $options, $folder);
?>