Skip to content

Installed but no output #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hycday opened this issue Nov 16, 2016 · 6 comments
Closed

Installed but no output #62

hycday opened this issue Nov 16, 2016 · 6 comments

Comments

@hycday
Copy link

hycday commented Nov 16, 2016

Hi,

I discovered your script and wanted to test it locally (Windows), so I did the following :

  • first I installed pdftk (it works, tested via command line).
  • then I installed composer, chose the php.exe.
  • then I downloaded php-pdftk and unpacked it in http://localhost/pdftk
  • then I opened command prompt in the pdftk folder and typed : composer require mikehaertl/php-pdftk and it created the vendor folder
  • I created an index.php file and had the following in it:
require_once('f:\pdftk\vendor\autoload.php');
use mikehaertl\pdftk\Pdf;
$pdf = new Pdf('a.pdf');
$pdf->fillForm('data.fdf')
 ->needAppearances();
   if (!$pdf->saveAs('bc.pdf')) {
    $error = $pdf->getError();
 echo $error;
}

Failed without error message: pdftk A="a.pdf" fill_form "data.fdf" output "C:\Windows\Temp\tmpE5BA.tmp.pdf" drop_xfa need_appearances

I tried as well with the functions to Generate FDF, to Get PDF data and to Fill form from FDF, and for each time, the page was blank with no errors.

Could you please tell me if I did something wrong in the steps, forgot something or how to debut it as I am certain that your script works but just don't know what is happening in my setup...

PS : just for info, when I do "pdftk a.pdf fill_form data.fdf output bc.pdf" in a command line, it works perfectly and the bc.pdf is well filled.

Thank you VERY much for your precious help.

hycday

@mikehaertl
Copy link
Owner

You need to set the path to your pdftk command, see https://github.com/mikehaertl/php-pdftk#execution

@hycday
Copy link
Author

hycday commented Nov 17, 2016

I just did and got the following :

Error: Unable to find file. Error: Failed to open PDF file: a.pdf Errors encountered. No output created. Done. Input errors, so no output created.

I guess that this is due to the fact that the path is

c:\Program Files (x86)\PDFtk Server\bin\pdftk.exe

but my server is on another hard drive (f:)

and on a an actual server the pdftk path might be outside of the domain (equivalent to this c:\ f:\ situation). So how to handle that ?

@mikehaertl
Copy link
Owner

The hard truth is: We don't really support Windows systems. While it basically should work, you're on your own, if it doesn't. You can check the underlying https://github.com/mikehaertl/php-shellcommand library, which we use to execute the command. We have some notes for windows users there.

There also was an issue with spaces in command names, see mikehaertl/php-shellcommand#1.

If you find out how to make it work, feel free to report back here, so that we can add some more tips to the README for windows users.

@PRodO5lNk5
Copy link

PRodO5lNk5 commented Nov 22, 2016

I managed to get the package to work on windows 10, the main issue (for me) was the path to the pdf template file, it must be apsolute e.g:
$pdf->fillForm('c:\Program Files (x86)\somefolder\pdf-template.pdf')
I hope it helps

@JavierCabezas
Copy link

I want to share what worked with me on windows 10.

  1. Installed PDFTk (https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/)
  2. Added pdftk to cli. The installer gives you the option to do this while installing. You can check if the program is added to your command line by executing the pdftk on powershell.
  3. Initialize Pdftk by doing:
    $pdftk = new PDFTK($pdf_url, [ 'command' => $pdftk_path, 'useExec' => true ]);
  • $pdf_url must be an absolute path.
  • $pdftk_path must be the path of your pdftk executable (Ex: 'C:\Program Files (x86)\PDFtk\bin\pdftk.exe')

And thats it!

@mikehaertl
Copy link
Owner

Added a note about setting the path on windows to the readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants