itext7 exception License file was corrupted when trying to run free trial

谁说胖子不能爱 提交于 2019-12-13 16:05:39

问题


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?

来源:https://stackoverflow.com/questions/44256013/itext7-exception-license-file-was-corrupted-when-trying-to-run-free-trial

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!