0
我正在使用Asp.Net MVC,並且我構建了一個返回pdf文件的控制器。 我建有PdfSharp的PDF:Asp.net mvc ajax用參數打開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文件。除此之外,我想將參數傳遞給控制器。
在此先感謝!
大解決方法:) – Anokrize