Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Generating pdf tutorials under laravel Framework

Shulou Source: shulou.com Published: 2022-06-02 10:08:33 09月25日 Update

This article mainly introduces "generating pdf tutorials under the laravel framework". In daily operation, I believe many people have doubts about generating pdf tutorials under the laravel framework. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "generating pdf tutorials under the laravel framework". Next, please follow the editor to study!

Baidu has two choices, laravel-dompdf and laravel-snappy, written by an author.

Laravel-dompdf was chosen at the beginning, because it is easier to transplant than the latter, but when it comes to the problem of garbled Chinese characters, it is useless to try several solutions. I heard that other people think highly of laravel-snappy, so I switched to the latter.

Github address: https://github.com/barryvdh/laravel-snappy

First of all, for the record, I only need to generate pdf, not pictures.

Step 1: install Wkhtmltopdf

Download Wkhtmltopdf (https://github.com/KnpLabs/snappy#wkhtmltopdf-binary-as-composer-dependencies), I use composer mode:

Composer require h5cc/wkhtmltopdf-amd64 0.12.x

This is the only sentence on the whole page that works for me.

Step 2: install laravel-snappy

Go back to the laravel-snappy (https://github.com/barryvdh/laravel-snappy) page

Cp vendor/h5cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 / usr/local/bin/chmod + x / usr/local/bin/wkhtmltopdf-amd64

I didn't use these two sentences for portability. If multiple projects need to be converted to pdf, you can refer to this method.

After the configuration file is generated, there are two ways to reference wkhtmltopdf:

Mode one

'binary' = > base_path (' vendor/h5cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'), / / the one I use

Mode two

'binary' = >' / usr/local/bin/wkhtmltopdf-amd64', / / linux environment 'binary' = >' "C:\ Program Files\ wkhtmltopdf\ bin\ wkhtmltopdf" / / windows environment

Finally, to solve the problem of Chinese garbled code, search a Chinese font library on the Internet and put it on / usr/share/fonts/ (my server is CentOS7,windows to find a solution / wink). I downloaded sumsin.ttf (https://ufonts.com/download/simsun.html) here.

These are the only points you need to pay attention to. Just refer to the official tutorials for others.

At this point, the study of "generating pdf tutorials under the framework of laravel" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Generation tutorials methods frameworks learning problems garbled solutions more environment solutions pages Chinese reference help migration selection utility next two Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Apple Microsoft OPPO Reno MySQL