我正在使用免费版的NReco将html转换为pdf。 pdf将在默认文件夹“Downloads”中下载。我需要自定义它。谁能帮我?
谢谢!
修改 在默认文件夹中下载pdf的代码是:
var pdfBytes = pdfConverter.GeneratePdf(strHtml);
Response.ContentType = "application/pdf";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AddHeader("Content-Disposition", "attachment; filename=TEST.pdf");
Response.BinaryWrite(pdfBytes);
Response.TransmitFile(output_path_pdf);
Response.Flush();
Response.End();
答案 0 :(得分:0)
此解决方案不会将PDF作为附件下载,而是直接将其下载到所选路径中,它解决了我的问题。
string output_path_pdf = HttpContext.Server.MapPath("~/PDF_RESULT/" + fileName + ".pdf");
HtmlToPdfConverter pdfConverter = new HtmlToPdfConverter();
pdfConverter.PageWidth = 1000;
pdfConverter.PageHeight = 800;
pdfConverter.Margins = new PageMargins { Top = 0, Bottom = 0, Left = 0, Right = 0 };
pdfConverter.GeneratePdfFromFiles(new string[] { URL }, null, output_path_pdf);