Generate PDF from .docx generated by PHPWord

前端 未结 4 1347
梦如初夏
梦如初夏 2021-01-01 21:07

I am creating .docx files from a template using PHPWord. It works fine but now I want to convert the generated file to PDF.

Fi

4条回答
  •  Happy的楠姐
    2021-01-01 21:37

    Try this:

    // get the name of the input PDF
    $inputFile = "C:\\PHP\\Test1.docx";
    
    // get the name of the output MS-WORD file
    $outputFile = "C:\\PHP\\Test1.pdf";
    
    try
        {
        $oLoader = new COM("easyPDF.Loader.8");
        $oPrinter = $oLoader->LoadObject("easyPDF.Printer.8");
        $oPrintJob = $oPrinter->PrintJob;
        $oPrintJob->PrintOut ($inputFile, $outputFile);
        print "Success";
        }
    
    
    catch(com_exception $e)
        {
        Print "error code".$e->getcode(). "\n";
        print $e->getMessage();
        }
    

提交回复
热议问题