Re: Create pdf from asp.net
Probably this is the key fo itextsharp:
this.Page.RenderControl(hw);
If I can render an already made html page then it can continue to export the pdf....
Re: Create pdf from asp.net
Hi,
We either use PdfSharpCore or DinkToPDF for our projects' reporting module. If you want to use an html page as template for the report, DinkToPDF is capable of that. Here's an example of using DinkToPDF in .NET Core app with a sample project available for download at Github.
kgc
Re: Create pdf from asp.net
Hence the issue that I must had written. It is note applicable to the old asp.net. Also pdfsharp is "free" with exceptions if I am not mistaken. Hence I used HtmlRenderer.PdfSharp.
Code:
string html = File.ReadAllText("C:\\zzzzzasppdf\\1.html");
PdfSharp.Pdf.PdfDocument pdf1 = TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.GeneratePdf(html, PdfSharp.PageSize.Letter);
pdf1.Save("C:\\zzzzzasppdf\\1.pdf");
PdfSharp.Pdf.PdfDocument x = new PdfSharp.Pdf.PdfDocument();
Byte[] res = null;
using (MemoryStream ms = new MemoryStream())
{
var pdf = TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.GeneratePdf("C:\\zzzzzasppdf\\1.html", PdfSharp.PageSize.A4);
pdf.Save(ms);
res = ms.ToArray();
}
Funny thing the project is not in codeplex anymore and I could only find 2-3 examples anywhere.
Nevertheless we decided to just show an HTML page on browser that the user will do a print-as , and create the pdf there.
If anything changes I will come back.
Thanks