is there any way to generate PDF through Page. RRS feed

  • Question

  • HI ,

    I want to generate PDF through page with same look and feel,with proper footer and header. 

    I tried Itextsharp Free version of DLL ,it's generated PDF quit fine but not perfect. 

    Can you please suggest me any microsoft DLL  or sample code.


    Kapil Khare

    Thanks, Kapil Khare

    Wednesday, July 8, 2020 2:21 AM

All replies

  • You can also try Spire.PDF nuget package to convert web pages to pdf. 

    Example code:

                PdfDocument doc = new PdfDocument();
                PdfPageSettings setting = new PdfPageSettings();
                setting.Size = new SizeF(1000, 1000);
                setting.Margins = new Spire.Pdf.Graphics.PdfMargins(20);
                PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();
                htmlLayoutFormat.IsWaiting = true;
                String url = "url";
                Thread thread = new Thread(() =>
                    doc.LoadFromHTML(url, false, false, false, setting, htmlLayoutFormat);

    • Edited by Shawn Sh Wednesday, July 8, 2020 6:56 AM
    Wednesday, July 8, 2020 6:52 AM
  • MS doesn't have any support for PDFs. You have to use a third party library. iTextSharp is the most common free library in use. There are always problems converting to PDFs irrelevant of the library you use. I recommend you get your code written to the best of your ability and then post a question in the forums for the library you're using (e.g. iTextSharp). This forum is for C#-specific questions only. We don't provide support for third party libraries so you'll need to request help from the library provider. Often it is just tweaking the settings properly. We use iTextSharp to generate 1000s of PDFs and we don't have issues making it look like the original SSRS or Word document it started from. It's all in the settings.

    Michael Taylor

    Wednesday, July 8, 2020 1:11 PM
  • Hi Kapil Khare,
    As CoolDadTx said, you need to use a third party library. And we don't provide support for third party libraries, so you'll need to request help from the library provider. 
    About generating PDF through Pag, there is more discussion in this link. Such as you can use wkhtmltopdf.
    Hope it could be helpful.
    Best Regards,
    Daniel Zhang

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Friday, July 10, 2020 8:08 AM