duanran3115 2015-03-17 12:06
浏览 155

在PHP中将docx转换为pdf

Right first a little background that will help put this all in focus. I have several indd files (indesign). I can convert these to pdf and then to docx.

Using the phpword library I can then effectively do a mail merge and replace several areas of my document with text and one image.

I then want to convert that to a pdf, which I can then stitch several pdfs together for printing with ghostscript.

I have a word macro that I can execute just find via standard command line functions. If I try that same command line in php it just hangs.

I've tried various forms of that, using system, exec, passthru - using Psexec all either hang and then timeout, or don't work and skip through.

I've seen other examples using COM objects thing like this. http://www.sitepoint.com/make-microsoft-word-documents-php/ all either hang or give me problems with the com object that I'm trying to make.

Am I trying for the impossible, or perhaps is there another way. I've also given e-PDF Document Converter v2.1 a go but without success.

Currently I'm thinking that there is some permission thing going on but I'm really at a loss as to how to get around it or what to do.

I would maybe like to use either the libreoffice or the openoffice as they both seem to have command line tools but when I open the pdf or the doc file they display very poorly.

Any help. Thanks Richard


Update Just thinking maybe I'll stitch the word documents together and then just allow the user to download it and then they can print it. Job done easy!

But if there is a better way - I'm open to it.


Update 2 On a windows platform

  • 写回答

1条回答 默认 最新

  • dongqun1656 2015-03-17 12:18
    关注

    Maybe something like next ?

    sudo apt-get install unoconv
    doc2pdf respondus-docx-sample-file.docx
    

    In php :

    exec("doc2pdf \"" . $youPdfFile . "\"");
    
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么