*/ /** * EDIT AREA BEGIN */ //the http host (or IP) of the server, where this script is hosted $htmlVersionHost = 'http://ubuntu.amstetten.at/'; //the absolute path to the document root of the above mentioned server $docRootPath = '/var/www/'; //the relative path (from document root) to the folder, where the html files should be stored $relStorePath = 'tmp/pdf2html'; //the absolute path to the pdftohtml library $pdfToHtmlPath = '/usr/bin/pdftohtml'; //the options for the pdftohtml command (type pdftohtml -help for a list of possible options) $pdfToHtmlOptions = '-q -dev jpeg -c -noframes'; /* END OF EDIT AREA */ //get the url to the pdf file witch should be converted $pdfURL = _GET('url'); //create a random number for the html filename $rand = mt_rand(); //get the pdf file and store a copy of it temporary getstore($docRootPath.$relStorePath,$rand.'.pdf',$pdfURL); //configure and execute the pdftohtml command $cmd = $pdfToHtmlPath.' '.$pdfToHtmlOptions.' '.$docRootPath.$relStorePath.$rand.'.pdf '.$docRootPath.$relStorePath.$rand; $exec = exec($cmd, $info); //delete the temporary stored pdf file unlink($docRootPath.$relStorePath.$rand.'.pdf'); //redirect to the fresh generated html file header("Location: ".$htmlVersionSiteUrl.$relStorePath.$rand.'.html'); /** * Returns the global GET array (or value from) normalized to contain un-escaped values. * * @param string Optional pointer to value in GET array (basically name of GET var) * @return mixed If $var is set it returns the value of $_GET[$var]. If $var is NULL (default), returns $_GET itself. In any case *slashes are stipped from the output!* */ function _GET($var=NULL) { $value = ($var === NULL) ? $_GET : (empty($var) ? NULL : $_GET[$var]); if (isset($value)) { // Removes slashes since TYPO3 has added them regardless of magic_quotes setting. if (is_array($value)) { stripSlashesOnArray($value); } else { $value = stripslashes($value); } } return $value; } /** * This function traverses a multidimentional array and strips slashes to the values. * * @param array Multidimensional input array, (REFERENCE!) * @return array */ function stripSlashesOnArray(&$theArray) { if (is_array($theArray)) { reset($theArray); while(list($Akey,$AVal)=each($theArray)) { if (is_array($AVal)) { stripSlashesOnArray($theArray[$Akey]); } else { $theArray[$Akey] = stripslashes($AVal); } } reset($theArray); } } /** * Store a temporary copy of the given (pdf-)file using CURL * * @param string absolute path to folder(!) where the copy should be stored * @param string the filename of the copy * @param string the url to the original file */ function getstore($path,$file,$url){ $ch = curl_init($url); $fp = fopen($path.$file, 'w'); //set curl session options curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); //exec curl curl_exec($ch); //close curl session curl_close($ch); fclose($fp); } ?>