Ah π I see whatβs happening.
That System.NotImplementedException
in ExpertPdf usually happens when:
The wrong class is used (they have HtmlToPdfConverter
and PdfConverter
in different namespaces/packages).
The library is not properly referenced / trial DLL mismatch.
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.