-
Nov 21st, 2023, 09:54 AM
#1
Create pdf from asp.net
I have seen itextsharp but an exable require to have a ready page to do so.
Is there any way to somehow create a page and pass it through?
I haven't search much for now but if there is an option I can investigate.
Thanks.
Edit:
I also have a version of CrystalDecisions.CrystalReports.Engine.ReportDocument
If it can be done from this component...Haven't check tho.
Last edited by sapator; Nov 21st, 2023 at 09:57 AM.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Nov 21st, 2023, 10:49 AM
#2
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....
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Nov 22nd, 2023, 06:04 AM
#3
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
-
Nov 22nd, 2023, 09:41 AM
#4
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
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|