简体   繁体   English

如何使用c#将html字符串转换为pdf

[英]how convert html string to pdf using c#

i have a string variable with html code and need convert to pdf the code of the variable, the variable is filled with the data of one gridview 我有一个带有html代码的字符串变量,需要将变量的代码转换为pdf,该变量充满了一个gridview的数据

<div>
<table>
<tr>
<td>Name</td>
<td>Cuty</td>
<td>Other Row</td>
<tr>
<td>Jonh</td>
<td></td>
<td></td>
<tr>
<tr>
<td>Name</td>
<td style="background-color:#00AA55;">Mary</td>
<td></td>
<td></td>
<tr>
</table>
</div>

and i need convert this table in pdf including the row style. 并且我需要将此表转换为pdf,包括行样式。 currently use itext library but don't add the style on the document 当前使用itext库,但未在文档中添加样式

If you want a lot of painstaking work - create your own html -> pdf converter using PDFSharp ( http://pdfsharp.com/ ). 如果您需要大量工作,请使用PDFSharp( http://pdfsharp.com/ )创建自己的html-> pdf转换器。 However, depending on the usage, I've heard using the internet explorer COM is a good solution. 但是,根据使用情况,我听说使用Internet Explorer COM是一个很好的解决方案。 You can always print an HTML page to a virtual PDF printer. 您始终可以将HTML页面打印到虚拟PDF打印机。

Use PDFizer , whenever you have valid xHTML (which you should always have). 只要您具有有效的xHTML(应始终具有),请使用PDFizer

It's pretty much the most reliable library out there. 它几乎是那里最可靠的库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM