【发布时间】:2018-04-30 17:08:25
【问题描述】:
我有一个链接,点击它,HTML 页面将被转换为 PDF 文档,然后将此 PDF 文件返回给用户。
HTML 代码:
<li><a href='@Url.Action("GetHTMLPageAsPDF", "Transaction", new { empID = employee.emplID })'>ViewReceipt</a></li>
后面的代码:
public FileResult GetHTMLPageAsPDF(long empID)
{
string htmlPagePath = "anypath...";
// convert html page to pdf
PageToPDF obj_PageToPDF = new PageToPDF();
byte[] databytes = obj_PageToPDF.ConvertURLToPDF(htmlPagePath);
// return resulted pdf document
FileResult fileResult = new FileContentResult(databytes, "application/pdf");
fileResult.FileDownloadName = empID + ".pdf";
return fileResult;
}
问题是当这个文件直接返回下载到用户计算机时,我想把这个PDF文件显示给用户,然后他可以下载。
我该怎么做?
【问题讨论】:
标签: c# asp.net-mvc html-to-pdf fileresult