itext7 exception License file was corrupted when t

2019-07-11 19:24发布

I am evaluating itext7 Html2pdf library. I registered for a free trial, downloaded the itextkey.xml license key and included it in my project.

Here is the code I am using:

public static readonly string destinationFile = @"C:\Test\Generated.pdf";
public static readonly string sourceHtml = @"C:\Test\djigit.html";
public static readonly string licenseKey = @"C:\Test\itextkey.xml";

static void Main(string[] args) {
    parsePdf(sourceHtml, destinationFile);
}

private static void parsePdf(string htmlSource, string pdfDestionation) {
    LicenseKey.LoadLicenseFile(licenseKey);
    PdfWriter writer = new PdfWriter(pdfDestionation);
    PdfDocument document = new PdfDocument(writer);

    HtmlConverter.ConvertToPdf(new FileStream(htmlSource, FileMode.Open), document);

    document.Close();
}

When I run the project I get the following exception:

iText.License.LicenseKeyException: License file was corrupted.

I included all the nuget packages described in the itext7 documentation in order to work: itext7, itext7.licensekey and itext7.pdfhtml.

Could you please tell me what I am doing wrong?

标签: c# .net pdf itext7
0条回答
登录 后发表回答