iText7: Unable to read license key json file

Viewed 36

I am trying to load the license file of iText7 in my Dot Net application (C# programming language). I have given the correct path to the json file using the syntax mentioned below.

LicenseKey.LoadLicenseFile(new FileStream(@"pathtofile\iTextKey.json", FileMode.Open)); 

The error message I get is:

Data at the root level is invalid. Line 1, position 1.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
   at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at iText.License.Util.XmlWorker..ctor(Stream stream)
   at iText.License.LicenseKey.LoadLicenseFileInternal(Stream licenseIs)
   at iText.License.LicenseKey.LoadLicenseFile(Stream licenseIs)

I verified the JSON file and it looks okay to me.

Any help to resolve this issue will be of great help.

1 Answers

As you can read from the stack trace, it's trying to parse the file as XML.

See docs:

However, if you have a JSON license key file, see the instructions for iText 7.2.x.

Install iText 7.2.

Related