我有,我想用iTextSharp
.HTML模板位於以下位置HTML到PDF使用iTextSharp的圖書館在ASP.NET
到使用Server.Mappath轉換
Html Template to pdf
方案(「〜/模板/ CertificateMailTemplate的.html「)
這是下面的代碼,我已經試過
public string SendCertificate()
{
try
{
byte[] outputstream = null;
using (var stream = new MemoryStream())
{
using (var document = new Document())
{
using (var writer = PdfWriter.GetInstance(document, stream))
{
document.Open();
using (var html = new StringReader(Server.MapPath("~/Template/CertificateMailTemplate.html")))
{
XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, html);
}
}
}
outputstream = stream.ToArray();
}
//Mail sending code
return "success";
}
catch (Exception ex)
{
return ex.Message;
}
finally
{
if (reader != null)
{
reader.Dispose();
}
}
}
在這裏,我收到以下錯誤The document has no pages.
任何幫助將不勝感激。
權!我仍然陷入了Java 5的困境。:) –