Closed crouti closed 9 years ago
I think you faced the same issue as this one: #171.
You should use Composer autoloader instead of Snappy's one.
require __DIR__ . '/vendor/autoload.php';
Thank you but, it's been installed in root dir, so how to properly set the permissions on it ? Thanks
2015-07-31 17:40 GMT+02:00 Jeremy Barthe notifications@github.com:
I think you faced the same issue as this one: #171 https://github.com/KnpLabs/snappy/issues/171. You should use Composer autoloader instead of Snappy's one. require DIR . '/vendor/autoload.php';
— Reply to this email directly or view it on GitHub https://github.com/KnpLabs/snappy/issues/175#issuecomment-126727371.
Max UNGER 09.54.69.54.53
www.termel.fr
Also, i don't have any Symfony installed, do i absolutely need it ?
knplabs/knp-snappy
has only a dependency to one Symfony component (symfony/process
) so you don't need to install the whole Symfony framework.
Basically if you have installed Snappy through Composer like that composer require knplabs/knp-snappy
you just need to require this autoload file:
require __DIR__ . '/vendor/autoload.php';
Yes i did installed Snappy through Composer, but i find the autoload inside /root/vendor/ and i am wondering how to link to it from php, which still says Permission denied when trying to access with suggested method. Do i need a symbolic link inside my webroot ? How ? Thank you very much
My referencing file is inside my wordpress custom plugin directory.
@crouti you need to run composer install
in your webroot or in your plugin directory, not in your user home dir. Or have you executed composer global install
?
Ok thanks, i didn't ran it into my plugin dir, i'll try that right now.
I've just installed composer in my plugin dir, then snappy and process, but i have now a runtime exception:
`PHP Fatal error: Uncaught exception 'RuntimeException' with message 'The exit status code '1' says something went wrong: stderr: "wkhtmltopdf: cannot connect to X server``
Any idea ?
@crouti well, snappy works :) which wkhtmltopdf version are you using?
wkhtmltopdf 0.9.9 from apt-get on ubuntu LTS
@crouti as stated in Snappy README, You will have to download wkhtmltopdf 0.12.x in order to use Snappy.
. You can either download deb package from http://wkhtmltopdf.org/ or you can also install in through composer as described in README
Oh, sorry, my fault, i then used: http://askubuntu.com/questions/556667/how-to-install-wkhtmltopdf-0-12-1-on-ubuntu-server
ti install
wkhtmltopdf 0.12.0 final
i restarted apache2 server, but still got the same error....
it seems i have to restart my server...
unfortunately, same problem after server restart...
had to reinstall pre-packaged version : http://wkhtmltopdf.org/downloads.html
the test : wkhtmltopdf http://www.google.com test.pdf
works
@crouti and from Snappy side?
seems to almost work, but can't make the file open in my browser (or available for download) with following command
header('Content-Type: application/pdf');
//header('Content-Disposition: attachment; filename="file.pdf"');
echo $snappy->getOutput('http://www.github.com');
in firefox
Can't see how to make it work... no error outputed in log, but no file appearing in browser... Here is my complete function:
function doff_process_ajax_show_pdf_preview() {
log_me('doff_show_pdf_preview');
$doff_template_result = do_shortcode( '[doff-custom-header]' );
$snappy = new Pdf(PATH_TO_WKHTMLTOPDF);
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="file.pdf"');
$args = array();
echo $snappy->getOutputFromHtml($doff_template_result,$args,true);
log_me('END::doff_show_pdf_preview');
die();
}
although file writing works, with
$snappy->generateFromHtml(myhtml, $filename);
for example.
any idea ? thanks a lot
@crouti Snappy uses file_get_contents
to retrieve the content. If fetching of remote URL does not work, it might be http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen.
allow_url_fopen = On
in my php.ini
is it a problem if i generate the file within an ajax jquery call ?
without ajax call, seems to work in Firefox, but not in chrome
@crouti you can't download a file with AJAX call. You should either request file generation and oncomplete redirect the user to the file endpoint or use libs like https://github.com/johnculviner/jquery.fileDownload to stream the content and save it on user machine. Anyway, it is not related to Snappy at all and to the first issue as well. Please, feel free to open a new issue if you need any help with Snappy.
Thank you very much!
I installed the package in my webroot (Ubuntu) and correctly inserted php code in my wordpress plugin. But, generating pdf (whichever method : generateFromHtml,getOutputFromHtml, getOutput, ...) i get the following error :
`PHP Fatal error: Class 'Symfony\Component\Process\Process' not found in /var/www/snappy-master/src/Knp/Snappy/AbstractGenerator.php on line 467``
Do i need Symfony to use snappy ? Thank you very much