问题
I'm looking into using PDFtk, but I have several questions that I'm just going to bundle together. (Let me know if they should be asked separately.)
- How would I install it on my shared web server? I use WebHostingHub, and their servers run CentOS.
- How do you use it? I'm not sure how to run a command-line tool through PHP, which is what I assume I would need to do. I don't have any experience with running anything command-line as an automated process like this. (I use domPDF to convert form results to a .pdf, but I'll need to attach an additional page to the end from a separate document that the user will upload. This is why I'm using PDFtk.)
As a note, my server does not provide ssh access. I can contact support, however, if absolutely necessary, and they may be able to install it for me.
回答1:
How would I install it on my shared web server?
You can include the binaries in your app, and then set the environment path to the bin
folder which holds the binaries.
$ mkdir -p [my_project]/vendor/pdftk/lib [my_project]vendor/pdftk/bin
$ cd /tmp
$ git clone https://github.com/millie/pdftk-source.git
$ cd pdftk-source
$ tar xzvf pdftk.tar.gz
$ mv bin/pdftk [my_project]/vendor/pdftk/bin/
$ mv lib/libgcj.so.12 [my_project]/vendor/pdftk/lib/
$ cd [my_project]
How do you use it?
First, read the PDF Labs Documentation, and then post if you have a question on how to do something specific
回答2:
First thing is you need to have root access to install PDFtk which you don't with a shared hosting account. The only shared hosting company I could find that has it preinstalled on all their servers is BlueHost.com. I started with a shared hosting account and now have my own VPS. When you get an account with them you don't need to do any setup on the server side, everything is preinstalled.
Below is a link to PDFtk's manual page. You can also Google lots of code examples. http://www.pdflabs.com/docs/pdftk-man-page/
来源:https://stackoverflow.com/questions/15669192/using-pdftk-on-a-shared-server