【发布时间】:2017-11-04 07:27:36
【问题描述】:
我正在使用 ASP.NET MVC,并构建了一个返回 PDF 文件的控制器。
我用 PDFsharp 构建 PDF:
public ActionResult GenerateReport(string Param)
{
// Create a new PDF document
PdfDocument document = new PdfDocument();
document.Info.Title = "Created with PDFsharp";
// Create an empty page
PdfPage page = document.AddPage();
// Get an XGraphics object for drawing
XGraphics gfx = XGraphics.FromPdfPage(page);
// Create a font
XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
// Draw the text
gfx.DrawString("Hello, World!", font, XBrushes.Black,
new XRect(0, 0, page.Width, page.Height),
XStringFormats.Center);
MemoryStream stream = new MemoryStream();
document.Save(stream, false);
byte[] bytes = stream.ToArray();
return File(bytes, "application/pdf");
}
现在我的目标是从 jQuery 发送 AJAX 请求并在新选项卡中打开 PDF 文件。除此之外,我想将参数传递给控制器。
【问题讨论】:
标签: jquery asp.net ajax pdf pdfsharp