Click here to Skip to main content
11,490,973 members (72,676 online)
Click here to Skip to main content

Convert html to PDF

, 15 Mar 2013 CPOL 24.8K 16
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? Pin
Ihtsham ul haq9-Sep-14 2:34
memberIhtsham ul haq9-Sep-14 2:34 
AnswerRe: What did you change? Pin
Hasan Hyder9-Sep-14 7:20
groupHasan Hyder9-Sep-14 7:20 
QuestionHow to support Chinese characters or UTF-8 characters ? Pin
gotolnc6-Jul-13 15:42
membergotolnc6-Jul-13 15:42 
AnswerRe: How to support Chinese characters or UTF-8 characters ? Pin
gotolnc6-Jul-13 15:47
membergotolnc6-Jul-13 15:47 
GeneralMy vote of 5 Pin
Prasad Khandekar15-Mar-13 5:52
memberPrasad Khandekar15-Mar-13 5:52 
GeneralRe: My vote of 5 Pin
Hasan Hyder17-Mar-13 23:50
groupHasan Hyder17-Mar-13 23:50 
GeneralMy vote of 4 Pin
Nerijus_Vax14-Mar-13 4:47
memberNerijus_Vax14-Mar-13 4:47 
GeneralRe: My vote of 4 [modified] Pin
Hasan Hyder14-Mar-13 20:14
groupHasan 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
Web02 | 2.8.150520.1 | Last Updated 15 Mar 2013
Article Copyright 2013 by Hasan Hyder
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid