Exception Handling  

System.NotImplementedException in ExpertPdf usually happens

Ah πŸ‘ I see what’s happening.

That System.NotImplementedException in ExpertPdf usually happens when:

  1. The wrong class is used (they have HtmlToPdfConverter and PdfConverter in different namespaces/packages).

  2. The library is not properly referenced / trial DLL mismatch.

  3. You’re calling a method that isn’t implemented in the trial version.


βœ… Correct Usage (ExpertPdf)

The correct main class is HtmlToPdfConverter, not PdfConverter.
Your earlier snippet used ExpertPdf.HtmlToPdf.PdfConverter, which is old / deprecated in some versions.

Here’s a working WebForms example:

using System;
using ExpertPdf.HtmlToPdf;

public partial class Default : System.Web.UI.Page
{
    protected void btnConvert_Click(object sender, EventArgs e)
    {
        // Create converter
        HtmlToPdfConverter pdfConverter = new HtmlToPdfConverter();

        // License key (leave empty for demo/trial)
        pdfConverter.LicenseKey = "YOUR-LICENSE-KEY";

        // PDF options
        pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
        pdfConverter.PdfDocumentOptions.LeftMargin = 20;
        pdfConverter.PdfDocumentOptions.RightMargin = 20;

        // Simple HTML content
        string rawHtml = @"
            <html>
              <body style='font-family:Arial; text-align:center;'>
                <h1 style='color:darkblue;'>Hello ExpertPdf!</h1>
                <p>This is a <b>sample</b> PDF generated from HTML.</p>
              </body>
            </html>";

        // Convert HTML string β†’ PDF bytes
        byte[] pdfBytes = pdfConverter.ConvertHtmlToPdfDocument(rawHtml, null);

        // Send PDF to browser
        Response.Clear();
        Response.ContentType = "application/pdf";
        Response.AddHeader("Content-Disposition", "attachment; filename=Sample.pdf");
        Response.BinaryWrite(pdfBytes);
        Response.End();
    }
}

πŸ”‘ Changes Made

  • βœ… Switched from PdfConverter β†’ HtmlToPdfConverter (correct class).

  • βœ… Used ConvertHtmlToPdfDocument(html, baseUrl) instead of unimplemented trial methods.

  • βœ… Cleaned HTML to minimal example.