barryvdh / laravel-snappy

Laravel Snappy PDF
MIT License
2.64k stars 291 forks source link

what file? #1

Closed Feqg closed 4 years ago

Feqg commented 10 years ago

what is the file to add this: 'binary' => base_path('vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'), And its route, thank you

barryvdh commented 10 years ago

It is the path to the wkhtmltopdf binary. If you install it via composer (see readme) it looks something like that. And there is no route for it.

Feqg commented 10 years ago

i am using laravel, so i dont understand that, i want to create a pdf but the new pdf is blank. thank you

barryvdh commented 10 years ago

Did you follow the instructions as linked in the readme? https://github.com/KnpLabs/snappy#wkhtmltopdf-binary-as-composer-dependencies You can try running the binary to see if it works. This is just a wrapper for Snappy, which is a wrapper for wkhtmltopdf, so see there for more info. If it doesnt work, maybe https://github.com/barryvdh/laravel-dompdf is a simpler solution..

Feqg commented 10 years ago

with laravel-dompdf i have problem with css bootstrap 3, the pdf is mixed up. i installed this: { "require": { "h4cc/wkhtmltopdf-amd64": "0.11.0-RC1", "h4cc/wkhtmltoimage-amd64": "0.11.0-RC1" } } and runned "update composer"...

do i have to do this?

<?php

use Knp\Snappy\Pdf;

$myProjetDirectory = '/path/to/my/project';

$snappy = new Pdf($myProjectDirectory . '/vendor/h4cc/wkhtmltopdf-i386/bin/wkhtmltopdf-i386');

// or

$snappy = new Pdf($myProjectDirectory . '/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64');

and where?

barryvdh commented 10 years ago

No just use the examples in the readme. And check your log for errors. Op 3 mrt. 2014 07:44 schreef "Feqg" notifications@github.com:

with laravel-dompdf i have problem with css bootstrap 3, the pdf is mixed up. i installed this: { "require": { "h4cc/wkhtmltopdf-amd64": "0.11.0-RC1", "h4cc/wkhtmltoimage-amd64": "0.11.0-RC1" } } and runned "update composer"...

do i have to do this?

<?php

use Knp\Snappy\Pdf;

$myProjetDirectory = '/path/to/my/project';

$snappy = new Pdf($myProjectDirectory . '/vendor/h4cc/wkhtmltopdf-i386/bin/wkhtmltopdf-i386');

// or

$snappy = new Pdf($myProjectDirectory . '/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64');

and where?

Reply to this email directly or view it on GitHubhttps://github.com/barryvdh/laravel-snappy/issues/1#issuecomment-36485192 .

Feqg commented 10 years ago

only i got this pdfmalo

from this example:

$pdf = App::make('snappy.pdf.wrapper'); $pdf->loadHTML('Test'); return $pdf->stream();

from readme. thak you

barryvdh commented 10 years ago

No errors in your error log? Perhaps you don't have the correct package for your system.

csoutham commented 10 years ago

This took me a while to figure out too. On a Mac I needed to installed an older version of wkhtmltopdf into my /usr/local/bin and then reference it in the package config file. There seems to be a bit of build problem with latest wkhtmltopdf on the Mac too.

I can see the confusion in your readme doc - the config path mentioned at the top needs to go in your package config once published.

hardy2defy commented 10 years ago

im having the same issue as Feqg, it only displays a gray background with the loading thing without even moving

I tried using these binary path, still not working.

 'binary' => base_path().'/vendor/h4cc/wkhtmltopdf-i386/bin/wkhtmltopdf-i386',
 'binary' => base_path().'\vendor\h4cc\wkhtmltopdf-i386\bin\wkhtmltopdf-i386',
barryvdh commented 10 years ago

And does the binary work standalone for you?

barryvdh commented 10 years ago
  1. make sure you have the right package (i386 vs amd64)
  2. Update to the h4cc 0.12.x release (if you are stil on 0.11.rc2)
  3. Test if the path is correct by running it with --version (eg. from your base dir: vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 --version)
  4. Try to generate a pdf: vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 http://google.com google.pdf

If google.pdf displays the google website, your wkhtmltopdf install is working, and the problem lies here. Otherwise it is a problem with wkhtmltopdf.

silverdr commented 10 years ago

The original question was: "what is the file to add this: 'binary' => base_path('vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64')".

readme.md says: "You have to set the binary location in the config file"

I have the very same question as the original: what is the "config file" I have to set the binary location in?

barryvdh commented 10 years ago

Publish the config:

php artisan config:publish barryvdh/laravel-snappy

Then it should be in app/config/packages/barryvdh/laravel-snappy/config.php

silverdr commented 10 years ago

Thanks! This works.

There is one more thing, however. The binaries installed according to the instructions you link to are dynamically linked and the installation does not take care of dependencies. Hence the binaries fail when run:

vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64: error while loading shared libraries: libXrender.so.1: cannot open shared object file: No such file or directory

Sure I know it's not your "fault". It's just that a few additional words about those issues in the readme.md would be quite useful.

Regards.

barryvdh commented 10 years ago

Sure, feel free to submit a PR to improve the Readme

silverdr commented 10 years ago

Fair enough ;-)

When installing I got a suggestion to use google/ instead of h4cc/ and the suggestion named a 0.11.??-RC1 (or similar). I don't know if it is related but maybe you know / experienced something similar. The version installed gives me invalid pdfs and when run from command line it says (among seemingly correct messages) that:

Fontconfig warning: ignoring UTF-8: not a valid region tag   ] 33%

Any clues? Thanks in advance.

neo710 commented 10 years ago

Hi, I have some troubles configuring the directive addOptions() in Knp/Snappy/Image.php.

I use laravel4 and I use Snappy to get thumbs of html code edited by users. All works but one thing: thumbs won't load images. Below my addOptions conf:

$this->addOptions(array(
            'allow'                        => array('/img', '/filemanager'),    // Allow the file or files from the specified folder to be loaded (repeatable)
            'checkbox-checked-svg'         => null,    // Use this SVG file when rendering checked checkboxes
            'checked-svg'                  => null,    // Use this SVG file when rendering unchecked checkboxes
            'cookie'                       => array(), // Set an additional cookie (repeatable)
            'cookie-jar'                   => null,    // Read and write cookies from and to the supplied cookie jar file
            'crop-h'                       => null,    // Set height for croping
            'crop-w'                       => null,    // Set width for croping
            'crop-x'                       => null,    // Set x coordinate for croping (default 0)
            'crop-y'                       => null,    // Set y coordinate for croping (default 0)
            'custom-header'                => array(), // Set an additional HTTP header (repeatable)
            'custom-header-propagation'    => null,    // Add HTTP headers specified by --custom-header for each resource request.
            'no-custom-header-propagation' => null,    // Do not add HTTP headers specified by --custom-header for each resource request.
            'debug-javascript'             => null,    // Show javascript debugging output
            'no-debug-javascript'          => null,    // Do not show javascript debugging output (default)
            'encoding'                     => 'UTF-8',    // Set the default text encoding, for input
            'format'                       => $this->getDefaultExtension(),   // Output format
            'height'                       => 700,    // Set screen height (default is calculated from page content) (default 0)
            'images'                       => true,    // Do load or print images (default)
            'no-images'                    => null,    // Do not load or print images
            'disable-javascript'           => null,    // Do not allow web pages to run javascript
            'enable-javascript'            => true,    // Do allow web pages to run javascript (default)
            'javascript-delay'             => 500,    // Wait some milliseconds for javascript finish (default 200)
            'load-error-handling'          => 'ignore',    // Specify how to handle pages that fail to load: abort, ignore or skip (default abort)
            'disable-local-file-access'    => null,    // Do not allowed conversion of a local file to read in other local files, unless explecitily allowed with allow
            'enable-local-file-access'     => true,    // Allowed conversion of a local file to read in other local files. (default)
            'minimum-font-size'            => null,    // Minimum font size
            'password'                     => null,    // HTTP Authentication password
            'disable-plugins'              => null,    // Disable installed plugins (default)
            'enable-plugins'               => null,    // Enable installed plugins (plugins will likely not work)
            'post'                         => array(), // Add an additional post field
            'post-file'                    => array(), // Post an additional file
            'proxy'                        => null,    // Use a proxy
            'quality'                      => 94,    // Output image quality (between 0 and 100) (default 94)
            'radiobutton-checked-svg'      => null,    // Use this SVG file when rendering checked radiobuttons
            'radiobutton-svg'              => null,    // Use this SVG file when rendering unchecked radiobuttons
            'run-script'                   => null,    // Run this additional javascript after the page is done loading (repeatable)
            'disable-smart-width'          => null,    // Use the specified width even if it is not large enough for the content
            'enable-smart-width'           => null,    // Extend --width to fit unbreakable content (default)
            'stop-slow-scripts'            => null,    // Stop slow running javascripts
            'no-stop-slow-scripts'         => null,    // Do not stop slow running javascripts (default)
            'transparent'                  => null,    // Make the background transparrent in pngs *
            'use-xserver'                  => null,    // Use the X server (some plugins and other stuff might not work without X11)
            'user-style-sheet'             => null,    // Specify a user style sheet, to load with every page
            'username'                     => null,    // HTTP Authentication username
            'width'                        => 700,    // Set screen width (default is 1024)
            'window-status'                => null,    // Wait until window.status is equal to this string before rendering page
            'zoom'                         => null,    // Use this zoom factor (default 1)
        ));

Is there any documentation that explain clearly those options? By the way where I goes wrong?

Thanks.

barryvdh commented 10 years ago

You should probably ask at https://github.com/KnpLabs/snappy THis is just a wrapper for Laravel

Hesesses commented 9 years ago

I'm getting this error:

vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64: error while loading shared libraries: libXrender.so.1: cannot open shared object file: No such file or directory

Any ideas how to fix this?

silverdr commented 9 years ago

By installing libXrender? There is a sentence about it at the beginning of README.md…

chikitovivas commented 9 years ago

how to set up the bootstrap grid, for this pdf generator?

majidkamal-vbase commented 8 years ago

where to add this line 'binary' => base_path('vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'). and also i am unable to run this command php artisan config:publish barryvdh/laravel-snappy.

brudascacosmin commented 7 years ago

Hi, I just installed laravel-snappy, and try to follow example from readme: $pdf = App::make('snappy.pdf.wrapper'); $pdf->loadView('invoice.show', [ $data ]); return $pdf->download('invoice.pdf'); But i see the fallowing error in log: Invalid request (Unexpected EOF) If I use loadHtml function it work fine. Any ideas how to figure out what it is happening here?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any issues with PDF rendering itself that are not directly related to this package, should be reported on https://github.com/KnpLabs/snappy instead. When having doubts, please try to reproduce the issue with just snappy. If you believe this is an actual issue with the latest version of laravel-snappy, please reply to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.