doubingjiu3199 2012-02-03 14:17
浏览 107
已采纳

在linux centos上通过php运行pdftk

I would like to run pdftk on my webserver. It's a Linux Centos with PHP 5.3.2.

When I connect it by commande line I do

pdftk --version

It's OK

pdftk A=p1-9.pdf cat A1 output p1.pdf

It's OK.

Now, I do this by php :

exec(pdftk A=p1-9.pdf cat A1 output p1.pdf)

It isn't OK. Why?? I search about the link of file, but it looks OK.

This doesn't work too :

exec(pdftk --version)

I install pdftk with this How do I install Pdftk on my server?

So what's wrong??

Thank for your help!

  • 写回答

1条回答 默认 最新

  • douche3791 2012-02-03 14:54
    关注

    I've run into this issue before. Assuming that you're wrapping your commands string in quotes (as gioele noted), the issue may be that you need to set your path when running the system command. Try this:

    $command = "pdftk A=p1-9.pdf cat A1 output p1.pdf";
    system("PATH=\$PATH:/usr/bin/ && $command",$response);
    if ($response===FALSE){
       //there was an error, handle it
    }
    

    (I've added a little response handling there as well). If that doesn't work, check to see what path you should use (it will depend on where you installed PDFTK).

    I believe you can also get the same result by using putenv("PATH=" .[your path]); and I've used system() here, but exec() should be affected in the same way

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件