HTML to PDF and image

Source: Internet
Author: User
Tags wkhtmltopdf

In the Web project, you need to download the Pdf/image feature, and send it as an attachment to the mailbox, with the help of this tool--wkhtmltopdf, the program generated Dynamic Web page HTML stored to the server, and then use it to convert HTML into pdf/image.

Under Windows, test on the command line after the installation is complete:

------> Generate PDF

Take the blog garden as an example

The cnblog.conf is generated under the bin

Open and look.

------> Generate image

or a blog park as an example

D:\wkhtmltopdf\bin>wkhtmltoimage.exe Https://www.cnblogs.com/cnblog.png

The cnblog.png is generated under the bin, the effect is as follows

Of course, you can crop the picture

D:\wkhtmltopdf\bin>wkhtmltoimage.exe--crop-w--crop-h Https://www.cnblogs.com/cnblog1.png

This creates a PNG image of 800*600

You can also specify an offset

D:\wkhtmltopdf\bin>wkhtmltoimage.exe--crop-w--crop-h--crop-x--crop-y Cnblog2.png

Cnblog2.png is the horizontal offset 100px, vertical offset 200px, and then intercept the 800*600 picture

More parameters,--help view (image default maximum width 1024, want to specify a larger width,--width)

------> Calls in PHP

Shell_exec ("D:\wkhtmltopdf\bin\wkhtmltoimage--crop-w 375--crop-h 667 $filename. html $filename. png");

HTML to PDF and image

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.