Barryvdh/laravel – snappy notes:
Again, laravel - is snappy in knplabs/KNP - snappy laravel integration, and the underlying use wkhtmltopdf/wkhtmltoimage pack 1. Install wkhtmltopdf 1 > from wkhtmltopdf official installation: https://wkhtmltopdf.org/downloads.html 2 > dependence as a composer to install: https://github.com/KnpLabs/snappy#wkhtmltopdf-binary-as-composer-dependencies 32-bit system: Composer require h4cc/wkhtmltopdf-i386 0.12.x Composer require H4cc /wkhtmltoimage-i386 0.12.x X composer require h4cc/wkhtmltopdf-amd64 0.12.x h4cc/wkhtmltoimage-amd64 0.12.x LibXrender, we need to install 2 ourselves manually. To test whether the wkhtmltopdf installation is successful, run the wkhtmltopdf command directly from the command line and use the second method to install (as a dependent installation of composer). / vendor/h4cc/wkhtmltoimage amd64 / bin/vendor/h4cc/wkhtmltopdf - amd64 / bin note: vagrant users need to undertake the following, to avoid a 126 error: 1> Move the downloaded binary software to a path that is not in the sync folder, for example: cp vendor/h4cc/wkhtmltoimage-amd64/bin/wkhtmltoimage-amd64 /usr/local/bin/ cp Vendor /h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 /usr/local/bin/2 > Add executable permission: Chmod + x/usr/local/bin/wkhtmltoimage - amd64 chmod + x/usr/local/bin/wkhtmltopdf - amd64 3. Barryvdh/laravel - after installation and use 1> Composer installation: Composer require BarryvDH /laravel-snappy Laravel 5.5 already uses package automatic discovery, we do not need to manually add 'ServiceProvider/Facade'. Conflicts may occur if 'laravel-dompdf' is used. In this case, the Facade needs to be registered manually to solve the problem (not intended to be used, but used, in case of conflict, remember this tip!). 2>config/app.php providers: Barryvdh \ Snappy \ ServiceProvider: : class, aliases: 'PDF' => Barryvdh\Snappy\Facades\SnappyPdf::class, 'SnappyImage' => Barryvdh\Snappy\Facades\SnappyImage::class, 3> Publish profile: PHP artisan vendor:publish --provider="Barryvdh\Snappy\ServiceProvider" Wkhtmltopdf and wkhtmlToImage paths 4> use: 1. $snappy = :make('snappy. PDF '); $html = '<h1>dongxuemin</h1>'; $snappy->generateFromHtml($HTML, '/ TMP /test.pdf'); $snappy->generate('http://www.github.com', '/ TMP /test.php'); $pdF_Response = $snappy->getOutputFromHtml($HTML); Return response($pdf_response, 200, [' content-type '=> 'application/ PDF ', 'Content-Disposition' => 'attachment; filename="file.pdf"' ]); $PDF = App::make('snappy. Pdf.wrapper '); $html = '<h1>dongxuemin</h1>'; $PDF ->loadHTML($HTML); return $pdf->inline(); 3. Use a Facade: $PDF = PDF::loadView('invoice.blade.php', $view_data) return $PDF ->download('invoice.pdf'); Return PDF::loadFile('http://www.github.com')->inline('github. PDF '); // Change orientation and paper size PDF::loadHTML($HTML) ->setPaper(' A4 ') // Paper size ->setOrientation('landscape') // Orientation ->setOption('margin-bottom', 0) ->save('myfile.pdf'); // ->output(); / / get the output string 4. For more information and parameters setting, reference wkhtmltopdf document: http://wkhtmltopdf.org/usage/wkhtmltopdf.txt 4. MAC system uses the 'second' installation method, error: / XXX /wkhtmltopdf-amd64 cannot execute binary file/XXX /wkhtmltopdf-amd64 cannot execute binary file/XXX /wkhtmltopdf-amd64 cannot execute binary fileCopy the code