1

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;
Lukas
  • 38
  • 4
  • 1
    *"Method not found: Boolean iText.Licence.LicenceKey.IsTrial()."* - this error message sounds like your specific iText library version and iText license library version are not compatible. I particular the pdfxfa version appears to rely on an older licencekey version while your iText core relies on the new one. – mkl Dec 16 '17 at 09:29
  • Go back to v2.0.4 of itext.licencekey library solves problem. Thanks @mkl – Lukas Dec 16 '17 at 10:53
  • Ok. I'll make that an actual answer later. – mkl Dec 16 '17 at 11:14

1 Answers1

3

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.

mkl
  • 90,588
  • 15
  • 125
  • 265
  • That is entirely correct, and pdfXFA 2.0.0 is scheduled to be released in January. pdfXFA wasn't released in December because pdfXFA is released at the same time as XFAWorker, and XFAWorker is tied to the iText 5 release schedule (iText 5.5.13). – Amedee Van Gasse Dec 18 '17 at 07:58