Maintain CSS styling when converting HTML to PDF in ASP.NET
Have a look at WKHTMLTOPDF. It is open source, based on webkit and free.
We wrote a small tutorial here.
ASP.Net to PDF conversion
Having worked with iText's old HTML->PDF code, I can suggest that you:
- Accept more answers to your questions. :P
- Don't do that. iText's HTML->PDF converter is acceptable, but its CSS support is still spotty. The new XMLWorker is an improvement, but there's still Much Better Options available to you.
I've been a committer on iText for a couple years now. HTML->PDF conversion is not its strength. Getting better, still a long way to go.
In particular, I'm quite happy with the results from WKHTML2PDF. I was able to render an HTML page with a GOOGLE MAP to PDF. You won't find that anywhere else (other than a browser's theoretical "current page to PDF" function, which I haven't heard of as yet).
Convert HTML content to Pdf using c# and asp.net
Try to replace width='200px' with width='200' it should work. Remove px from every places with width.
Open Source HTML to PDF Renderer with Full CSS Support
I've always used it on the command line and not as a library, but HTMLDOC gives me excellent results, and it handles at least some CSS (I couldn't easily see how much).
Here's a sample command line
htmldoc --webpage -t pdf --size letter --fontsize 10pt index.html > index.pdf
Convert html tagged text to string for a pdf itext7
I created "Hello World" here and used bold, italic and underline. Copy the source code via "Tools" and just use the following code to convert it via iText7:
String htmlString = "<p><span style=\"text-decoration: underline;\"><em><strong>Hello World</strong></em></span></p>";
HtmlConverter.convertToPdf(htmlString, new PdfWriter(destinationFolder + "test.pdf"));
The resultanting PDF:
Related Topics
How to Disable Automatic Links Coloring Without Selecting a Color
CSS Difference Between Attribute Selectors with Tilde and Star
Box-Shadow and Border-Radius Bug in Chrome
Twitter Bootstrap - Same Heights on Fluid Columns
Rtl Is on Web Page Reverses Numbers with a Dash
Pixel Density, Retina Display and Font-Size in CSS
How to Set a Flex-Container to Be the Width of Its Flex-Items
React Pseudo Selector Inline Styling
How to Reset Default Button Style in Firefox 4 +
Css3 Radial Gradients with Rgba()
How to Use Bootstrap 4 Flexbox to Fill Available Content
Make Second Div Appear Above First, Without Absolute Position or Changing HTML
Bootstrap Navbar Collapse Media-Query on Custom Width
On CSS: If Text Line Is Break Show Dots
Is It Bad Practice to Use Negative Margins or Padding in CSS