* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License */ /** * Display command line usage */ function dompdf_usage() { $default_paper_size = DOMPDF_DEFAULT_PAPER_SIZE; echo <<set_option('enable_php', false); if ( isset($_GET["input_file"]) ) $file = rawurldecode($_GET["input_file"]); else throw new DOMPDF_Exception("An input file is required (i.e. input_file _GET variable)."); if ( isset($_GET["paper"]) ) $paper = rawurldecode($_GET["paper"]); else $paper = DOMPDF_DEFAULT_PAPER_SIZE; if ( isset($_GET["orientation"]) ) $orientation = rawurldecode($_GET["orientation"]); else $orientation = "portrait"; if ( isset($_GET["base_path"]) ) { $base_path = rawurldecode($_GET["base_path"]); $file = $base_path . $file; # Set the input file } if ( isset($_GET["options"]) ) { $options = $_GET["options"]; } $file_parts = explode_url($file); $outfile = "dompdf_out.pdf"; # Don't allow them to set the output file $save_file = false; # Don't save the file break; } if ( $file === "-" ) { $str = ""; while ( !feof(STDIN) ) $str .= fread(STDIN, 4096); $dompdf->load_html($str); } else $dompdf->load_html_file($file); if ( isset($base_path) ) { $dompdf->set_base_path($base_path); } $dompdf->set_paper($paper, $orientation); $dompdf->render(); if ( $_dompdf_show_warnings ) { global $_dompdf_warnings; foreach ($_dompdf_warnings as $msg) echo $msg . "\n"; echo $dompdf->get_canvas()->get_cpdf()->messages; flush(); } if ( $save_file ) { // if ( !is_writable($outfile) ) // throw new DOMPDF_Exception("'$outfile' is not writable."); if ( strtolower(DOMPDF_PDF_BACKEND) === "gd" ) $outfile = str_replace(".pdf", ".png", $outfile); list($proto, $host, $path, $file) = explode_url($outfile); if ( $proto != "" ) // i.e. not file:// $outfile = $file; // just save it locally, FIXME? could save it like wget: ./host/basepath/file $outfile = realpath(dirname($outfile)) . DIRECTORY_SEPARATOR . basename($outfile); if ( strpos($outfile, DOMPDF_CHROOT) !== 0 ) throw new DOMPDF_Exception("Permission denied."); file_put_contents($outfile, $dompdf->output( array("compress" => 0) )); exit(0); } if ( !headers_sent() ) { $dompdf->stream($outfile, $options); }