I would like to try iText7 PDF Flattening with trial licence. When Flatten method is called, it throws exception "Method not found: Boolean iText.Licence.LicenceKey.IsTrial()." Does it mean that Flatten method cannot be used with trial licence or I am doing some mistake? I use itext7 from NuGet, all components in latest stable versions: itext7 v7.1.0 itext7.licencekey v3.0.0 itext7.pdfxfa v1.0.2
And I have trial licence successfully loaded from .xml file.
Here is my code sample:
byte[] result;
LicenseKey.LoadLicenseFile(_path.MapPath("~/itextkey?????????????.xml"));
XFAFlattenerProperties flattenerProperties = new XFAFlattenerProperties()
.SetPdfVersion(XFAFlattenerProperties.PDF_1_7)
.CreateXmpMetaData()
.SetTagged()
.SetMetaData(
new MetaData()
.SetAuthor("xxxxxxx")
.SetSubject("xxxxxx")
.SetTitle("xxxxxx"));
XFAFlattener xfaf = new XFAFlattener()
.SetFontSettings(new XFAFontSettings().SetEmbedExternalFonts(true))
.SetFlattenerProperties(flattenerProperties)
.SetViewMode(XFAFlattener.ViewMode.SCREEN);
using (var dest = new MemoryStream())
{
xfaf.Flatten(new MemoryStream(source), dest);
result = dest.ToArray();
}
return result;
An error message like
Method not found: Boolean iText.Licence.LicenceKey.IsTrial().
usually indicates that incompatible libraries are in use. In the case at hand the (old) pdfxfa v1.0.2 does not get along well with the (new) licencekey v3.0.0.
As you eventually saw, Going back to v2.0.4 of itext.licencekey library solves problem.
If you take a look at the Compatibility Matrix in the Release notes for iText 7.1.0, you'll see that itext7 v7.1.0 and licencekey v3.0.0 are meant to work with pdfXFA v2.0.0. You might want to eventually use those versions.