Using Pechkin to convert HTML pages to PDF

Source: Internet
Author: User

Pechkin Open Source Components use Wkhtmlbox, you can parse CSS styles, convert Web pages to PDF files,

Support URL, or HTML string

1, get Pechkin from the NuGet program Manager

 globalconfig config = new GlobalConfig ();             simplepechkin Pechkin = new Simplepechkin (config);             objectconfig objectconfig = new Objectconfig ();             objectconfig.setprintbackground (True)                  . Setloadimages (True)                  . Setaffectpagecounts (True)                  . Setpageuri ("http://www.abc.com/");             byte [] bytepdf = Pechkin. Convert (Objectconfig);,             File.writeallbytes ("F:\\pdfname.pdf", bytePDF);  2,cpechkin, users of Pechkin are packaged, or can be obtained from NuGet


Synchronizedpechkin sc = new Synchronizedpechkin (New GlobalConfig ()
. SetMargins (New Margins () {left = 0, right = 0, Top = 0, Bottom = 0})//Set margin
. Setpaperorientation (true)); Set the paper orientation to landscape
//. Setpapersize (340, 594)); Set Paper size 50mm * 100mm
Objectconfig oc = new Objectconfig ();

Oc. Setpageuri ("http://localhost:40146/Styles/HTMLPage2.htm");
byte[] Buf = SC. Convert (OC);
Response.AddHeader ("Content-disposition", "attachment;filename=1.pdf");

Response.ContentType = "Application/octet-stream";
Response.BinaryWrite (BUF);

Using Pechkin to convert HTML pages to PDF

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.