Click here to Skip to main content
Click here to Skip to main content

Convert html to PDF

, 15 Mar 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
Application convert's html link into PDF file format.


Article is simple and based on WkHtmlToXSharp library which convert's html to PDF, here we had done little enhancement to fulfill our needs, hope this effort would serve you in some way.

   Download Application

Using the code  

Code is really simple, you just need to create and object and pass the URL to GetUrlPDF () function described below, which returns byte array, from here it can be converted to your desire stream. Here we had used file stream to put up the show.   

 WkHtmlToPdfConverter wol = new WkHtmlToPdfConverter();
            // Get PDF in bytes
            Byte[] bufferPDF = wol.GetUrlPDF(url);
            // Convert bytes to stream
            System.IO.FileStream writeStream = new System.IO.FileStream("sample.pdf",      System.IO.FileMode.Create, System.IO.FileAccess.Write);
            writeStream.Write(bufferPDF, 0, Convert.ToInt32(bufferPDF.Length));
            // Open PDF file



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Hasan Hyder
Software Developer
Pakistan Pakistan
No Biography provided
Group type: Organisation

29 members

Follow on   Google+

Comments and Discussions

QuestionWhat did you change? PinmemberIhtsham ul haq9-Sep-14 2:34 
AnswerRe: What did you change? PingroupHasan Hyder9-Sep-14 7:20 
QuestionHow to support Chinese characters or UTF-8 characters ? Pinmembergotolnc6-Jul-13 15:42 
AnswerRe: How to support Chinese characters or UTF-8 characters ? Pinmembergotolnc6-Jul-13 15:47 
GeneralMy vote of 5 PinmemberPrasad Khandekar15-Mar-13 5:52 
GeneralRe: My vote of 5 PingroupHasan Hyder17-Mar-13 23:50 
GeneralMy vote of 4 PinmemberNerijus_Vax14-Mar-13 4:47 
GeneralRe: My vote of 4 [modified] PingroupHasan Hyder14-Mar-13 20:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141216.1 | Last Updated 15 Mar 2013
Article Copyright 2013 by Hasan Hyder
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid