Skip to content
Loading
  • +1
    hey neeraj,
    creating pdf with c# is extremely easy process.
    you dont have to indulge in lengthy codes for this.
    you can use ZetPDF.com.
    it is very easy to use and doesnot require much time.
    hopefully, this will help you.
    thanks 
    +1
  • +1
    need help visit our website http://zetpdf.com/
    +1
  • Laxmidhar Sahoo
    +1
    add reference itextsharp from nugate and follow the link
     
    https://www.c-sharpcorner.com/article/convert-html-string-to-pdf-via-itextsharp-library-and-downlo/ 
    +1
  • +1
    You can try using LEADDocument.convert() method from LEADTOOLS to convert HTML to PDF. You can find more information here:
    https://www.leadtools.com/help/leadtools/v20/dh/javascript/dox/leaddocument-convert.html
    https://www.leadtools.com/sdk/document/document-converter
     
    Also, you can find the online project here:
    https://demo.leadtools.com/JavaScript/DocumentViewer/
     
    The following JavaScript code shows how you can do this using LEADTOOLS SDK:
    1. // JavaScript source code  
    2. var url = "http://www.MyWebSite.com/MyPage.html";  
    3. lt.Documents.DocumentFactory.loadFromUri(url, null)  
    4. .done(function (document) {  
    5. var myJobData = new lt.Documents.DocumentConverterJobData();  
    6. myJobData.documentFormat = lt.Documents.Writers.DocumentFormat.pdf;  
    7. myJobData.rasterImageFormat = lt.Documents.RasterImageFormat.unknown;  
    8. document.convert(myJobData)  
    9.    .done(function (result) {  
    10.       var resultDoc = result.document != null ? result.document.url : result.archive.url;  
    11.       window.open(resultDoc);  
    12.    })  
    13.    .fail(function (jqXHR, status1, error1) {  
    14.       alert("Error during converting document " + error1);  
    15.    });  
    16. })  
    17. .fail(function (jqXHR, status1, error1) {  
    18. alert("Error during loading document " + error1);  
    19. }); 
    Note that you can also do the conversion using LEADTOOLS Convert Cloud service for .NET. You can find more information with sample codes here:
    https://services.leadtools.com/documentation/tutorials
    https://services.leadtools.com/documentation/tutorials/net-cs-conversion-tutorial
    +1
  • Amit Kumar
    +1
    Hi, HtmlRenderer.PdfSharp is a 100% fully C# managed code, easy to use, thread safe and most importantly FREE (New BSD License) solution. Usage Download HtmlRenderer.PdfSharp nuget package. Use Example Method. public static Byte[] PdfSharpConvert(String html) { Byte[] res = null; using (MemoryStream ms = new MemoryStream()) { var pdf = TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.GeneratePdf(html, PdfSharp.PageSize.A4); pdf.Save(ms); res = ms.ToArray(); } return res; } A very Good Alternate Is a Free Version of iTextSharp For more detail : https://www.aspsnippets.com/Articles/Convert-ASPX-Page-to-PDF-using-iTextSharp-in-ASPNet-C-and-VBNet.aspx
    +1
  • Atir Tahir
    +1
    You can convert HTML to PDF easily using GroupDocs.Conversion for .NET. A back-end API https://products.groupdocs.com/conversion/net that could be intergrated in any .NET application (e.g. Web, Windows Form).
    Let's see how simple is the code:
    1. // Setup Conversion configuration and Initailize ConversionHandler    
    2. ConversionConfig config = new ConversionConfig();    
    3. config.StoragePath = "source file storage path";    
    4. // Initailize ConversionHandler    
    5. ConversionHandler conversionHandler = new ConversionHandler(config);    
    6. // Convert and save converted document    
    7. var convertedDocumentPath = conversionHandler.Convert("sample.html", new PdfSaveOptions{});    
    8. convertedDocumentPath.Save("result-" + Path.GetFileNameWithoutExtension("sample.html") + ".pdf");   
    +1
  • Mageshwaran R
    0
    Hi,
    Can you check with the below link:
    http://www.c-sharpcorner.com/UploadFile/9f0ae2/convert-aspx-page-into-pdf-in-Asp-Net/ 
    0