Visualizzazione dei risultati da 1 a 8 su 8

Discussione: convertire doc in pdf

  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2007
    Messaggi
    103

    convertire doc in pdf

    Ciao ragazzi ho trovato qst script in php, perke ho necessita di tradformare un documento testo in pdf,solo che non capisco cosa fa arrivato dalle parti di ActiveDocument.
    Innanzitutto Active Document cos'è?
    ho provato a trov sul manuale php ma nulla..e Printout???

    <?
    // starting word
    $word = new COM(”word.application”) or die(”Unable to instanciate Word”);
    // bring it to front
    $word->Visible = 1;
    // Select the acrobat distiller as the active printer.
    // I presume that you could also use the Acrobat PDF writer // driver that comes with Acrobat full version.
    $word->ActivePrinter = “Acrobat Distiller”;
    // Open a word document, or anything else that word
    // can read
    $word->Documents->Open($input);

    // This will create a .PS file called $output
    $word->ActiveDocument->PrintOut(0, 0, 0, $output);
    // If you need a .pdf instead, use the acrobat
    // distiller’s watched folder option.
    // closing word
    $word->Quit();
    // free the object
    $word->Release();
    $word = null;
    ?>

  2. #2
    usa fpdf:

    http://fpdf.org/

  3. #3
    Utente di HTML.it
    Registrato dal
    Oct 2007
    Messaggi
    103
    ciao, ma nn c'è nessuno script su questa classe che posso guardare..
    non sono molto bravo a program, e questa classe mi fa impostare troppi parametri che non conosco, a me serve semplicemente che il mio file doc venga trasfomato in pdf, senza cambiare alcun parametro..

  4. #4
    Utente di HTML.it
    Registrato dal
    Oct 2007
    Messaggi
    103
    Ciao ho trovato su un forum questo script

    Hi
    you'll need Ghostscript, this script and win2000 or lin
    best regards
    ToM
    codice:
    <?
    $printername="PDF-Datei mit erweiterten Einstellungen"
    $psfile="C:\\temp\\".$_FILES['userfile']['name'].".ps";
    $pdffile="c:\\Apache2\\htdocs\\uploads\\".$_FILES['userfile']['name'].".pdf";
    $result_link="[b]Result: Open PDF Result\n";
    $uploaddir = 'c:\\Apache2\\htdocs\\uploads\\';
    $uploaded_doc=$uploaddir.$_FILES['userfile']['name'];
    $gsinst="c:\\gs\\gs8.13\\bin\\gswin32c.exe"
    ?>
    <head><title>PDF Document Converter</title></head>
    <body bgcolor="#FFFFFF" text="#000000" link="#0000FF">
    <table width="100%" border="0">
    <tr>
    <td width="94%">Office2PDF Conversion Service</td>
    </tr>
    <tr>
    <td>Supported Formats: doc, rtf, xls, ppt, txt, html, ps, eps</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 width="17%">Document-Password (if given): </td>
    <td width="83%"><input name="password" type="password"></td>
    </tr>
    <tr>
    <td>Quality: </td>
    <td><table width="200">
    <tr>
    <td><label>
    <input type="radio" name="quality" value="300dpi">
    300 DPI</label>
    </td>
    </tr>
    <tr>
    <td><label>
    <input type="radio" name="quality" value="600dpi">
    600 DPI</label>
    </td>
    </tr>
    <tr>
    <td><label>
    <input type="radio" name="quality" value="1200dpi">
    1200 DPI</label>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td>Start conversion</td>
    <td><input type="submit" name="send" value="send file">
    </td>
    </tr>
    </table>
    </form>
    <?
    if ($_POST['password']){
    $password=$_POST['password'];
    }
    else { $password="False"; }
    list ($name, $suffix) = split ('[.]', $_FILES['userfile']['name']);
    function excel($document, $ps_file, $pdf_file){
    $excel = new COM("excel.application") or die("Unable to instantiate Excel");
    $excel->AskToUpdateLinks = 0;
    $excel->Workbooks->Open($document);
    $excel->Workbooks[1]->Saved=1;
    $excel->Workbooks[1]->PrintOut(1, 5000, 1, False, $printername, True, False, $ps_file);
    $excel->Workbooks[1]->Close(false);
    $excel->Quit();
    $excel->Release();
    $excel = null;
    unset($excel);
    while (exec("$gsinst -sDEVICE=pdfwrite -r300 -dNOPAUSE -dBATCH -dSAFER -sPAPERSIZE=a4 -sOutputFile=\"".escapeshellcmd($pdf_file)."\" \"".escapeshellcmd($ps_file)."\"") > 0){
    sleep(1);
    }
    }
    function powerpoint($document, $ps_file, $pdf_file){
    $powerpoint = new COM("powerpoint.application") or die("Unable to instantiate Powerpoint");
    $powerpoint->Visible = 1;
    $powerpoint->Presentations->Open($document, False, False, False, False);
    $powerpoint->Presentations[1]->Saved=1;
    $powerpoint->ActivePrinter = $printername;
    $powerpoint->Presentations[1]->PrintOut(1, 5000, $ps_file, 0, False);
    $powerpoint->Presentations[1]->Close();
    $powerpoint->Quit();
    $powerpoint->Release();
    $powerpoint = null;
    unset($powerpoint);
    while (exec("$gsinst -sDEVICE=pdfwrite -r300 -dNOPAUSE -dBATCH -dSAFER -sPAPERSIZE=a4 -sOutputFile=\"".escapeshellcmd($pdf_file)."\" \"".escapeshellcmd($ps_file)."\"") > 0) {
    sleep(1);
    }
    }
    function word($document, $ps_file, $pdf_file, $passwd){
    $word = new COM("word.application") or die("Unable to instantiate Word");
    //$word->Visible = 0;
    $word->Documents->Open($document, False, True, False, $passwd);
    $word->Documents[1]->Saved = 1;
    $word->ActivePrinter = "PDF-Datei mit erweiterten Einstellungen";
    $word->Documents[1]->PrintOut(True, False, 0, $ps_file);
    while($word->BackgroundPrintingStatus > 0){
    sleep(1);
    }
    $word->Documents[1]->Close(false);
    $word->Quit();
    $word->Release();
    $word = null;
    unset($word);
    while (exec("$gsinst -sDEVICE=pdfwrite -r300 -dNOPAUSE -dBATCH -dSAFER -sPAPERSIZE=a4 -sOutputFile=\"".escapeshellcmd($pdf_file)."\" \"".escapeshellcmd($ps_file)."\"") > 0){
    sleep(1);
    }
    }
    if ($_POST['send']){
    print "<pre>";
    if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir.$_FILES['userfile']['name'])) {
    if ($suffix=="doc" || $suffix=="dot" || $suffix=="htm" || $suffix=="html" || $suffix=="txt" || $suffix=="rtf"){
    word($uploaded_doc, $psfile, $pdffile, $password);
    }
    elseif ($suffix=="xls" || $suffix=="xlt" || $suffix=="csv"){
    excel($uploaded_doc, $psfile, $pdffile);
    }
    elseif ($suffix=="ps" || $suffix=="prn" || $suffix=="eps"){
    while (exec("$gsinst -dBATCH -sDEVICE=pdfwrite -sOutputFile=\"c:\\apache2\\htdocs\\uploads\\".escapeshellcmd($pdffile)."\" -dNOPAUSE \"$uploaded_doc\"") > 0){
    sleep(1);
    }
    }
    elseif ($suffix=="ppt" || $suffix=="pps" || $suffix=="pot" || $suffix=="PPT"){
    powerpoint($uploaded_doc, $psfile, $pdffile);
    } else {
    echo'<font color="#FF0000">Dateiformat wird nicht unterstützt !!!</font>
    ';
    //exec("del \"$uploaded_doc\"");//Hochgeladene Datei löschen
    echo'<font color="#FF0000">Hochgeladene Datei wieder gelöscht.</font>';
    exit();
    }
    } else {
    echo '<font color="#FF0000">Datei konnte nicht hochgeladen werden !</font>';
    exit();
    }
    while (!(is_writable($pdffile))){
    sleep(1);
    }
    if (!headers_sent()) {
    $header="http://localhost/uploads/".$_FILES['userfile']['name'].".pdf";
    header ("Location: $header");
    exit();
    } else { echo 'Das Resultat befindet sich für 24 Stunden unter: '.$_FILES['userfile']['name'].'.pdf'; }
    exit();
    }
    ?>
    </BODY>

  5. #5
    Utente di HTML.it
    Registrato dal
    Oct 2007
    Messaggi
    103

    move_uploaded_file

    mm..ho dei problemi..innanzitutto ho settato in qst maniera le variabili:

    $printername="PDF-Datei mit erweiterten Einstellungen";
    $psfile="C:\\temp\\".$_FILES['userfile']['name'].".ps";
    $pdffile="C:\\Programmi\\Apache Group\\Apache2\\htdocs\\uploads\\".$_FILES['userfile']['name'].".pdf";
    $result_link="[b]Result: Open PDF Result\n";
    $uploaddir = 'C:\\Programmi\\Apache Group\\Apache2\\htdocs\\uploads\\';
    $uploaded_doc=$uploaddir.$_FILES['userfile']['name'];
    $gsinst="C:\\Programmi\\gs\\gs8.54\\bin\\gswin32c. exe"

    poi..ho qst due errori su move_uploaded_file per un documento word che non capisco perke mi vengono dati..

    Warning: move_uploaded_file(C:\Programmi\Apache Group\Apache2\htdocs\uploads\SCADENZE LAUREA.doc) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Programmi\Apache Group\Apache2\htdocs\gs.php on line 119

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\Documents and Settings\Habbiucc\Impostazioni locali\Temp\PHP\upload\php123.tmp' to 'C:\Programmi\Apache Group\Apache2\htdocs\uploads\SCADENZE LAUREA.doc' in C:\Programmi\Apache Group\Apache2\htdocs\gs.php on line 119

    Datei konnte nicht hochgeladen werden !

    avete qualche idea??

  6. #6
    Utente di HTML.it
    Registrato dal
    Jan 2006
    Messaggi
    245
    Per questo errore: failed to open stream: Permission denied, sicuramente il file non ha impostati tutti i diritti, devono essere impostati a 0777 (RWX)

  7. #7
    Utente di HTML.it
    Registrato dal
    Oct 2007
    Messaggi
    103
    come si fanno ad impostare quelle 0777 rwx??

  8. #8
    Utente di HTML.it
    Registrato dal
    Oct 2007
    Messaggi
    103
    c'è qlcn che lo sa?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.