/admin

Asp.net To Pdf Pdfsharp

Acdsee photo manager 12.0 build 342 keygen. Converting HTML to PDF in VB.Net with PDFSharp An interesting little problem we’ve had to implement for a client recently; how to take an HTML (passed through as an email attachment), and convert it to a PDF in a VB.net command line program. This article describes you how to convert asp.net repeater controls html or entire webpage to pdf using itextsharp. It will also give introduction to iTextSharp.

With our unique approach to crawling we index shared files withing hours after Upload.When you search for files (video, music, software, documents etc), you will always find high-quality gta 5 mod menu xbox one files recently uploaded on DownloadJoy or other most popular shared hosts.If search results are not what you looking for please give us feedback on where we can/or should improve. Gta mods xbox one. As an file sharing search engine DownloadJoy finds gta 5 mod menu xbox one files matching your search criteria among the files that has been seen recently in uploading sites by our search spider.

Page 1 of 1
[ 2 posts ]
Print viewPrevious topic Next topic
Pdf
AuthorMessage
Post subject:Generate and download pdf through browser

Joined: Fri Jul 27, 2018 3:29 am
Posts: 19
Hi, Im trying to use PDFSharp with Asp.Net Core 2.1. It working great, creating the pdf and save it to the path.
But it didn't show anything in the browser that the file has been downloaded to the browser default download path.
Here is my code:
namespace CreatePDF.Controllers
{
[Route('api/[controller]')]
public class CreatePDFController : Controller
{
// GET: api/<controller>
[HttpGet]
public IActionResult CreatePDF()
{
PDFGenerator.GeneratePDF();
return Ok('Successfully generate pdf.');
}
}
}

public class PDFGenerator
{
public static string GeneratePDF()
{
GlobalFontSettings.FontResolver = new FontResolver();
var document = new PdfDocument();
var page = document.AddPage();
var gfx = XGraphics.FromPdfPage(page);
var font = new XFont('OpenSans', 20, XFontStyle.Bold);
gfx.DrawString('Hello World!', font, XBrushes.Black, new XRect(20, 20, page.Width, page.Height), XStringFormats.Center);
document.Save('D:test.pdf');
return 'pdf generated';
}
}

So, when user click button. It will generate the pdf and download it through browser like below. How do I achieve this using PDFSharp and .Net Core?


Attachments:

10-PDF-downloaded-file.png [ 2.72 KiB Viewed 1435 times ]
Top
Post subject:Re: Generate and download pdf through browser
PDFsharp Expert

Joined: Sat Mar 14, 2015 10:15 am
Posts: 538
Location: CCAA
Hi!
The controller must send the PDF to the browser.
Here is a sample that does it with ASPX:
http://pdfsharp.net/wiki/Clock-sample.ashx
With ASP.NET MVC return the PDF file as the action result.
Maybe this helps you get started:
https://stackoverflow.com/a/29277790/1015447

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
Page 1 of 1
[ 2 posts ]