Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hi everey one,is possible export Html with External CssStyles( like background color,image) into pdf in Asp.net ? if it possible please give suggestion to me as soon possible....
Posted 5-Feb-13 17:30pm
Edited 5-Feb-13 18:20pm
v2
Comments
Sergey Alexandrovich Kryukov at 5-Feb-13 22:54pm
   
First of all, please don't re-post. I removed one redundant questions.
 
Apparently, you can create PDF, just use iTextSharp (but why?!).
What's the problem? What do you mean by giving a solution? You cannot expect that someone do your work for you...
—SA
Suresvision at 5-Feb-13 23:21pm
   
Hi,is possible export Html or aspx table with External CssStyles( like background color,image) into pdf in Asp.net ? if it possible please give suggestion to me as soon possible....
Sergey Alexandrovich Kryukov at 5-Feb-13 23:33pm
   
What suggestions do you mean? This is just work to do...
(Was that soon enough? :-))
—SA
Suresvision at 5-Feb-13 23:51pm
   
i am saving html to pdf but that pdf not showing css styles in pdf, i used itextsharp.
Sergey Alexandrovich Kryukov at 5-Feb-13 23:55pm
   
If is not supposed to "show" anything, you need to parse and interpret CSS. Nothing can do it but your code. There is no such thing as a miracle...
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Look at the wkhtmltopdf[^] project, which is “simple shell utility to convert html to pdf using the webkit rendering engine, and qt.” I'm using this in my project about two years and it works just fine.
Usage:
wkhtmltopdf www.myhomepage.com myhomepage.pdf
for local file:
wkhtmltopdf c:\path\to\file.html file.pdf
.html extension is mandatory, in case you want to work with temporary file!
 
For executing another programs from your code use Process Class[^] with ProcessStartInfo Class[^].
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hello!
You can use some 3rd party libraries to convert HTML to PDF. For examle you may want to look at Elerium HTML to PDF component. It allows to convert html string/file/url to PDF including styles, but it is not free. All you need is HTML file or string that contains a reference to an external css file.

You can also try iTextSharp. It is free but i don't know does it work with external styles correctly.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 PIEBALDconsult 110
4 Sergey Alexandrovich Kryukov 104
0 OriginalGriff 6,055
1 DamithSL 4,621
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,500
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 11 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100