Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Updated 5-Feb-13 17:20pm
v2
Comments
Sergey Alexandrovich Kryukov 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
Suri Rayal 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 5-Feb-13 23:33pm    
What suggestions do you mean? This is just work to do...
(Was that soon enough? :-))
—SA
Suri Rayal 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 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

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[^].
 
Share this answer
 
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900