Click here to Skip to main content
13,596,156 members
Click here to Skip to main content
Add your own
alternative version


17 bookmarked
Posted 14 Mar 2013
Licenced CPOL

Convert html to PDF

, 15 Mar 2013
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
This member doesn't quite have enough reputation to be able to display their biography and homepage.
Group type: Organisation

32 members

You may also be interested in...


Comments and Discussions

GeneralMessage Closed Pin
4-Oct-17 0:30
memberCodeFixUp com4-Oct-17 0:30 
QuestionGetUrlPDF(URL) does not work fine Pin
Shakeel Abbasi30-Sep-15 9:17
memberShakeel Abbasi30-Sep-15 9:17 
QuestionWhere's the source code to your addition? Pin
jnegron21518-Sep-15 5:44
memberjnegron21518-Sep-15 5:44 
AnswerRe: Where's the source code to your addition? Pin
Hasan Hyder20-Sep-15 21:26
groupHasan Hyder20-Sep-15 21:26 
QuestionWhat did you change? Pin
Ihtsham ul haq9-Sep-14 1:34
memberIhtsham ul haq9-Sep-14 1:34 
AnswerRe: What did you change? Pin
Hasan Hyder9-Sep-14 6:20
groupHasan Hyder9-Sep-14 6:20 
QuestionHow to support Chinese characters or UTF-8 characters ? Pin
gotolnc6-Jul-13 14:42
membergotolnc6-Jul-13 14:42 
AnswerRe: How to support Chinese characters or UTF-8 characters ? Pin
gotolnc6-Jul-13 14:47
membergotolnc6-Jul-13 14:47 
AnswerRe: How to support Chinese characters or UTF-8 characters ? Pin
Samuel-Summers5-Jul-15 23:30
memberSamuel-Summers5-Jul-15 23:30 
GeneralMy vote of 5 Pin
Prasad Khandekar15-Mar-13 4:52
memberPrasad Khandekar15-Mar-13 4:52 
GeneralRe: My vote of 5 Pin
Hasan Hyder17-Mar-13 22:50
groupHasan Hyder17-Mar-13 22:50 
GeneralMy vote of 4 Pin
Nerijus_Vax14-Mar-13 3:47
memberNerijus_Vax14-Mar-13 3:47 
GeneralRe: My vote of 4 Pin
Hasan Hyder14-Mar-13 19:14
groupHasan Hyder14-Mar-13 19:14 

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

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

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