Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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");
- }
- public ActionResult GenerateReport(string Param)
- {
- // same as before
- ....
- // save your pdf to a file
- File.WriteAllBytes("result.pdf", memoryStream.ToArray());
- // get url to that pdf which can be browsed
- var pdfUrl = "some location which url can browse";
- return Json(new {url = pdfUrl}, JsonBehaviour.AllowGet);
- }
- $.getJSON( "your GenerateReport url", function( data ) {
- window.open(data.url,'_blank');
- }
Add Comment
Please, Sign In to add comment