SkyRanger Posted May 15, 2007 Share Posted May 15, 2007 I am looking for a way to do a file conversion. I have found a number of scripts that allow me to change html2PDF but I am looking for a script or even example to get a starting point off of, I require a script that will allow me to change from DOC2PDF or any other ext2pdf. Does anybody know where I can find such thing. I checked to see if the pdflib was installed on my server. What I am trying to accomplish is: the user uploads a file for conversion, the pdf class converts it to pdf. The file is then saved onto the server. I have seen a bunch for windows servers also but I am running an apache server which does me no good. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/51518-solved-question/ Share on other sites More sharing options...
SkyRanger Posted May 15, 2007 Author Share Posted May 15, 2007 ~bump~ Quote Link to comment https://forums.phpfreaks.com/topic/51518-solved-question/#findComment-253899 Share on other sites More sharing options...
SkyRanger Posted May 15, 2007 Author Share Posted May 15, 2007 bump for the evening crew Quote Link to comment https://forums.phpfreaks.com/topic/51518-solved-question/#findComment-254015 Share on other sites More sharing options...
SkyRanger Posted May 16, 2007 Author Share Posted May 16, 2007 Ok, I got a start on it, but ran into a fatal error problem: <?php $gsinst="/usr/bin/ghostscript"; $quality = $_POST['quality']; $wordfiles = array("doc", "DOC", 'dot', 'DOT', 'rtf', 'RTF', 'tml', 'TML', 'htm', 'HTM', 'txt', 'TXT'); error_reporting(E_ALL ^ E_NOTICE); $servername = $HTTP_SERVER_VARS['SERVER_NAME']; $workdir = getcwd()."/"; $pdffile=$workdir.$_FILES['userfile']['name'].".pdf"; $uploaded_doc=$workdir.$_FILES['userfile']['name']; ?> <html> <head> <title>PDF Document Converter</title> </head> <body bgcolor="#FFFFFF" text="#000000" link="#0000FF"> <table width="100%" border="0"> <tr> <td width="94%"><b>Doc to PDF Conversion</b></td> </tr> <tr> <td> <?php echo "Supported File Endings: <br>"; foreach ($wordfiles as $value) { echo "$value, "; } ?> </td> </tr> </table> <form enctype="multipart/form-data" action="<?=$PHP_SELF ?>" method="post"> <table width="100%" border="0" bgcolor="#CCCCCC"> <tr> <td width="17%">Office File: </td> <td width="83%"><input name="userfile" type="file"></td> </tr> <tr> <td>Quality: </td> <td><table width="800"> <tr> <td><label> <input type="radio" checked name="quality" value="-dPDFSETTINGS=/default"> Default: Standard setting, middle sized PDFs, Acrobat 4 compatible</label> </td> </tr> <tr> <td><label> <input type="radio" name="quality" value="-dPDFSETTINGS=/screen"> Screen: small PDFs, especially for Internet, Acrobat 3 compatible</label> </td> </tr> <tr> <td><label> <input type="radio" name="quality" value="-dPDFSETTINGS=/ebook"> EBook: PDFs especially for e-Books (= middle Quality), Acrobat 4 compatible</label> </td> </tr> <tr> <td><label> <input type="radio" name="quality" value="-dPDFSETTINGS=/printer"> Printer: PDFs especially for Printing Documents (= good Quality), Acrobat 4 compatible</label> </td> </tr> <tr> <td><label> <input type="radio" name="quality" value="-dPDFSETTINGS=/prepress"> Prepress: PDFs especially for die Printing (= best Quality). Acrobat 4 compatible</label> </td> </tr> </table> </td> </tr> <tr> <td>Start conversion</td> <td><input type="submit" name="send" value="send file"> </td> </tr> </table> </form> <?php //If Document has Password, you can use this variable (works not with Powerpoint if ($_POST['password']){ $password=$_POST['password']; }else { $password="False"; } list ($name, $suffix) = split ('[.]', $_FILES['userfile']['name']); function word($document, $pdf_file, $passwd, $gs_inst, $printer_name, $out_quality){ //$word->Visible = 0; $word->Documents->Open($document, False, True, False, $passwd) or die("Unable to open document"); //$word->Documents[1]->Saved = 1; //$word->ActivePrinter = $printer_name; $word->Documents[1]->PrintOut(True, False, 0, $ps_file); while($word->BackgroundPrintingStatus > 0){ sleep(1); } $word->Documents[1]->Close(false); $word->Quit(); $word = null; unset($word); while (exec("$gs_inst -sDEVICE=pdfwrite -r300 $out_quality -dNOPAUSE -dBATCH -dSAFER -sPAPERSIZE=a4 -sOutputFile=\"".$pdf_file."\" \"".$ps_file."\"") > 0){ sleep(1); } } if ($_POST['send']){ print "<pre>"; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $workdir.$_FILES['userfile']['name'])) { if (in_array($suffix, $wordfiles)){ word($uploaded_doc, $pdffile, $password, $gsinst, $quality); } else { echo'<strong><font color="#FF0000">File format is not supported !!!</strong></font><br>'; unlink($uploaded_doc); echo'<strong><font color="#FF0000">File is too large.</strong></font>'; exit(); } } else { echo '<strong><font color="#FF0000">File could not be loaded !</strong></font>'; exit(); } while (!(is_writable($pdffile))){ sleep(1); } if (!headers_sent()) { $header="http://$servername/".$_FILES['userfile']['name'].".pdf"; header ("Location: $header"); unlink($psfile); unlink($uploaded_doc); exit(); } else { echo 'File will remain for 24 hours: <a href="http://'.$servername.'/'.$_FILES['userfile']['name'].'.pdf">'.$_FILES['userfile']['name'].'.pdf</a>'; } unlink($psfile); unlink($uploaded_doc); exit(); } ?> </BODY> </HTML> The error I am getting is: Fatal error: Class 'COM' not found in /home/prodco/public_html/members/pdf/convert.php on line 94 Quote Link to comment https://forums.phpfreaks.com/topic/51518-solved-question/#findComment-254084 Share on other sites More sharing options...
SkyRanger Posted May 16, 2007 Author Share Posted May 16, 2007 bump Quote Link to comment https://forums.phpfreaks.com/topic/51518-solved-question/#findComment-254138 Share on other sites More sharing options...
SkyRanger Posted May 16, 2007 Author Share Posted May 16, 2007 Anybody? Quote Link to comment https://forums.phpfreaks.com/topic/51518-solved-question/#findComment-254385 Share on other sites More sharing options...
Chesso Posted May 16, 2007 Share Posted May 16, 2007 Wouldn't this sort of thing be best suited to a windows (or cross platform) application that's a bit more native. Or is there a specific reason it needs to be online? Quote Link to comment https://forums.phpfreaks.com/topic/51518-solved-question/#findComment-254396 Share on other sites More sharing options...
SkyRanger Posted May 16, 2007 Author Share Posted May 16, 2007 Yeah, some of my clients have to convert there .doc and .fdr files into PDF to be able to ship off to there agents. They can write but are not very computer knowledgeable. So I wanted to set up a script like I see on some other sites to be able to do this for them where they just upload the file, it converts and they save it back to there computer. Quote Link to comment https://forums.phpfreaks.com/topic/51518-solved-question/#findComment-254402 Share on other sites More sharing options...
SkyRanger Posted May 16, 2007 Author Share Posted May 16, 2007 Well I can't figure this out so I am going to squash the project and just tell them to find a free one online, there are lots out there. Quote Link to comment https://forums.phpfreaks.com/topic/51518-solved-question/#findComment-254501 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.