使用ASP .NET将HTML页面的图像转换为pdf文件 [英] Background Image of HTML page into pdf file using ASP .NET
本文介绍了使用ASP .NET将HTML页面的图像转换为pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的html页面代码我希望将此html页面转换为PDF格式
This is my html page code i want to convert this html page into PDF format
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="Stylesheet" type="text/css" href="../../../CSS/style.css" />
</head>
<body>
<form id="form1" runat="server">
<div style="background:transparent url(WrittenTestCallLetter.jpg); height:1160px; background-repeat:no-repeat;">
</div>
<table>
<tr>
<td align="center"><asp:Button ID="btnSubmit" runat="server" Text="Submit"
onclick="btnSubmit_Click" /> </td>
</tr>
</table>
</form>
</body>
</html>
推荐答案
使用。
wkhtmltopdf.exe
在项目的bin文件夹中。
use.
wkhtmltopdf.exe
in bin folder of your project.
string url= @"http://www.google.com";
try
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.FileName = Server.MapPath("~/bin/") + "wkhtmltopdf.exe";
process.StartInfo.Arguments = "\""+ url+ " " + Server.MapPath("~/PDFFiles/") + "test.pdf\"";
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.Start();
process.WaitForExit();
}
catch (Exception ee)
{
//logging
}
或看到这个参考。
Pdfizer,一个愚蠢的HTML到PDF转换器,用C# [ ^ ]
这篇关于使用ASP .NET将HTML页面的图像转换为pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文