0

People think there is no way to run a php file without browser running, but there is by the help of android API; when the api runs some specific files in the server(for example server is xampp in the windows os) from android application I want to generate pdf file from the called php file by android. the real problem is it that, every output is sending through android console, not to the browser. how can I generate the pdf without browser running? any expert?

1 Answers1

0

Of course it is possible to generate a PDF without a Browser (HTTP request). I do that in my daily business. The trick is to run a PHP script from the console e.g. manually or automtically every x minutes via crontab (cronjobs).

Create a php file 'cronjob.php':

<?php

echo "Running\n";

echo "Processing\n";

echo "Done\n";

return 0;

Try to run: php cronjob.php

Output:

Running
Processing
Done

Add a crontab job:

$ crontab -e

append this line

* * * * * /usr/bin/php /var/www/cronjob/cronjob.php

To generate the PDF itself I would recommend a library like TCPDF (or mpdf).

odan
  • 4,757
  • 5
  • 20
  • 49