Invalid License Error

I recently purchased an Aspose.PDF Java Site OEM license, and I am trying to use it with Aspose PDF v25, but I am getting the below error:

 (main) com.aspose.pdf.License: Exception occur.
java.lang.IllegalStateException: The license is not valid for this product. For free technical support, please post this error and the file in the Aspose.PDF Forums http://www.aspose.com/community/forums/aspose.pdf-product-family/20/showforum.aspx

Here is the class where I am applying multiple licenses. In the past we had only a word license, but we are now adding PDF. I have tried swapping the order of license application to no success:

@Slf4j
@Singleton
public class AsposeLicenseService {
    private final String wordLicense;
    private final String pdfLicense;
    private final Map<LicenseType, Boolean> licenseStatusMap;

    @Inject
    public AsposeLicenseService(
            @Named(Constants.ASPOSE_WORD_LICENSE_SECRET_NAME) final String wordLicense,
            @Named(Constants.ASPOSE_PDF_LICENSE_SECRET_NAME) final String pdfLicense) {
        this.wordLicense = wordLicense;
        this.pdfLicense = pdfLicense;
        this.licenseStatusMap = new HashMap<>();
        applyAllLicenses();
    }

    public boolean applyAllLicenses() {
        boolean pdfSuccess = applyPdfLicense();
        boolean wordsSuccess = applyWordsLicense();
        return wordsSuccess && pdfSuccess;
    }

    public boolean applyWordsLicense() {
        if (isWordsLicensed()) {
            log.info("Aspose.Words is already licensed");
            return true;
        }
        if (StringUtils.isBlank(wordLicense)) {
            log.warn("No Aspose.Words license data provided, running in evaluation mode");
            licenseStatusMap.put(LicenseType.WORD, false);
            return false;
        }

        com.aspose.words.License license = new com.aspose.words.License();
        try (ByteArrayInputStream licenseStream = new ByteArrayInputStream(
                wordLicense.getBytes(StandardCharsets.UTF_8))) {
            license.setLicense(licenseStream);
            licenseStatusMap.put(LicenseType.WORD, true);
            log.info("Aspose.Words license applied successfully");
            return true;
        } catch (Exception e) {
            log.error("Failed to apply Aspose.Words license: {}", e.getMessage(), e);
            licenseStatusMap.put(LicenseType.WORD, false);
            return false;
        }
    }

    public boolean applyPdfLicense() {
        if (isPdfLicensed()) {
            log.info("Aspose.PDF is already licensed");
            return true;
        }
        if (StringUtils.isBlank(pdfLicense)) {
            log.warn("No Aspose.PDF license data provided, running in evaluation mode");
            licenseStatusMap.put(LicenseType.PDF, false);
            return false;
        }
        com.aspose.pdf.License license = new com.aspose.pdf.License();

        try (ByteArrayInputStream licenseStream = new ByteArrayInputStream(
                pdfLicense.getBytes(StandardCharsets.UTF_8))) {
            license.setLicense(licenseStream);
            licenseStatusMap.put(LicenseType.PDF, true);
            log.info("Aspose.PDF license applied successfully");
            return true;
        } catch (Exception e) {
            log.error("Failed to apply Aspose.PDF license: {}", e.getMessage(), e);
            licenseStatusMap.put(LicenseType.PDF, false);
            return false;
        }
    }

    public boolean isWordsLicensed() {
        return licenseStatusMap.getOrDefault(LicenseType.WORD, false);
    }

    public boolean isPdfLicensed() {
        return licenseStatusMap.getOrDefault(LicenseType.PDF, false);
    }

    enum LicenseType {
        WORD,
        PDF,
    }
}

We are using aspose-pdf-25.10.jar and aspose-words-25.9-jdk17.jar

@zikora

The exception is thrown when the license file that is being loaded does not contain a product entry that matches Aspose.PDF.
In the thread you posted a similar situation for an Aspose.Total license – the file had to be edited so that the <Product> node read Aspose.PDF (or Aspose.PDF for Java) before the PDF API would accept it. The same rule applies to a Site OEM license.

What to check / do

  1. Confirm the license type – it must be a Site OEM license that includes the PDF product. A Total‑for‑Java license works only if the <Product> node is set to Aspose.PDF (or Aspose.PDF for Java).
  2. Inspect the license XML (you can redact the key values). The <Product> element should look like one of the following:
    <Product>Aspose.PDF</Product>
    <!-- or -->
    <Product>Aspose.PDF for Java</Product>
    
    If it contains Aspose.Total or another product name, the PDF API will reject it.
  3. Load the license file without altering its bytes. If you store the license in a secret as a plain XML string, reading it with getBytes(StandardCharsets.UTF_8) is fine, but if the secret is Base64‑encoded you must decode it first:
    byte[] data = Base64.getDecoder().decode(pdfLicense);
    try (InputStream is = new ByteArrayInputStream(data)) {
        new com.aspose.pdf.License().setLicense(is);
    }
    
  4. Apply only the PDF license first (comment out the Words license) to rule out any cross‑product interference.
  5. Upgrade to the latest version (e.g., 25.11) and retest – newer builds contain a more tolerant license parser.

If after verifying the <Product> node the error persists, please attach a redacted copy of the license file (remove the private key) and the exact version numbers of the PDF and Words JARs you are using. We can then reproduce the issue and, if it turns out to be a defect, log it internally.

Here is the redacted license file, I have confirmed that the license type and product are as expected:

<?xml version="1.0"?>
<License>
    <Data>
        <LicensedTo>Company SERVICES LLC</LicensedTo>
        <EmailTo>********@company.com</EmailTo>
        <LicenseType>Site OEM</LicenseType>
        <LicenseNote>Up To 10 Developers And Unlimited Deployment Locations</LicenseNote>
        <OrderID>********</OrderID>
        <UserID>********</UserID>
        <OEM>This is a redistributable license</OEM>
        <Products>
            <Product>Aspose.PDF for Java</Product>
        </Products>
        <EditionType>Enterprise</EditionType>
        <SerialNumber>********-****-****-****-************</SerialNumber>
        <SubscriptionExpiry>20261208</SubscriptionExpiry>
        <LicenseVersion>3.0</LicenseVersion>
        <LicenseInstructions>https://purchase.aspose.com/policies/use-license</LicenseInstructions>
    </Data>
    <Signature>************************************************************************************************************************************************************************************************************************************************************************************************</Signature>
</License>

I have also tried applying only the PDF license, and I am still getting the same error. I even modified the code to include the license check outlined in Licensing and limitations|Aspose.PDF for Java with no luck:

    public boolean applyPdfLicense() {
        if (isPdfLicensed()) {
            log.info("Aspose.PDF is already licensed");
            return true;
        }
        if (StringUtils.isBlank(pdfLicense)) {
            log.warn("No Aspose.PDF license data provided, running in evaluation mode");
            licenseStatusMap.put(LicenseType.PDF, false);
            return false;
        }

        com.aspose.pdf.License license = new com.aspose.pdf.License();

        try (ByteArrayInputStream licenseStream = new ByteArrayInputStream(
                pdfLicense.getBytes(StandardCharsets.UTF_8))) {
            license.setLicense(licenseStream);
            if (com.aspose.pdf.Document.isLicensed()) {
                licenseStatusMap.put(LicenseType.PDF, true);
                log.info("Aspose.PDF license applied successfully");
                return true;
            } else {
                log.error("Aspose.PDF license was not applied successfully");
                licenseStatusMap.put(LicenseType.PDF, false);
                return false;
            }
        } catch (Exception e) {
            log.error("Failed to apply Aspose.PDF license: {}", e.getMessage(), e);
            licenseStatusMap.put(LicenseType.PDF, false);
            return false;
        }
    }

Instead, it returns the error:

(main) com.aspose.pdf.internal.l7f.lI: Exception occur.
java.io.EOFException: Unexpected end of ZLIB input stream
at java.base/java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:244)
at java.base/java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at com.aspose.pdf.internal.l7f.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l6k.lt.lI(Unknown Source)
at com.aspose.pdf.internal.l3p.lb.lI(Unknown Source)
at com.aspose.pdf.internal.l3p.lb.lI(Unknown Source)
at com.aspose.pdf.internal.l3p.lb.lI(Unknown Source)
at com.aspose.pdf.internal.l3p.lb.lI(Unknown Source)
at com.aspose.pdf.OperatorCollection.ld(Unknown Source)
at com.aspose.pdf.OperatorCollection.lu(Unknown Source)
at com.aspose.pdf.OperatorCollection.size(Unknown Source)
at com.aspose.pdf.BaseOperatorCollection.isEmpty(Unknown Source)
at com.aspose.pdf.ADocument.l1f(Unknown Source)
at com.aspose.pdf.ADocument.isLicensed(Unknown Source)

I have also tried updating to 25.11, but still getting the same error. Please would appreciate any help.

@zikora

Instead of loading license in bytes, have you tried loading it using file path? Please try in a simple console application with only Aspose.PDF for Java and see if issue is still there. In case it persists, please share your complete license file in a private message so that we can test the scenario in our environment and address it accordingly. You can send a private message by clicking on the username and pressing Blue Message button.

1 Like

Thanks for your response. I have tried to apply license from path to no success, I have sent a message following instructions at How to Send License File to Support Team

Please, still awaiting some help if possible, thanks!

@zikora

We tested your license with 25.7 as well as 25.11 version of the API and could not notice any issues in it. It was set successfully.

Have you tried above suggestion?