Results 1 to 4 of 4

Thread: Create pdf from asp.net

  1. #1

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,621

    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.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  2. #2

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,621

    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....
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    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
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  4. #4

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,621

    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
  •  



Click Here to Expand Forum to Full Width