Aspose licensing warning appearing after a long processing period

We are extracting text from PDF for thousands of PDF. Licensing works fine with no errors/warning in the extracted text. But suddenly for 5-6 documents out of the entire batch, we get the “warning” on licensing at the top of the extracted text. Like:
Evaluation Only. Created with AsposeR.PDéF. fCéopryreignht c20e01 -R202a5 Apspposoe rPtty

Why would it not recognized the licensing and the warning message is also cryptic, almost like it crashed or something. But the remaining of the extracted text is right there after the warning message.
And finally, if I reprocess those PDF, the text is extracted with no licensing warning.

Since it happens on a large scale of records, I can’t provide any sample docs.

Thanks

@brissonp

Summary
When you extract text from a PDF, an occasional leading line such as “Evaluation Only” appears. This indicates that the Aspose PDF for Java license was not in effect at the moment the document was opened, so the library operated in evaluation mode and inserted its watermark text, which is then returned as part of the extracted content.

Why it happens

Possible cause How it leads to the warning
License loaded after the first PDF operation – the License object is set later in the workflow (or inside a thread) and some PDFs are processed before it. Those PDFs are treated as evaluation files and the watermark text becomes part of the extracted output.
Multi‑threaded / web‑app environment – each thread or each class‑loader may need its own license initialization. A thread that never called new License().setLicense(...) works in evaluation mode.
Incorrect or relative license path – the path works for most runs but fails when the working directory changes (e.g., batch jobs, scheduled tasks). The library cannot find the license file, so it silently falls back to evaluation mode for that run.
Corrupted or expired license file – the file cannot be read correctly (I/O error) or the license has expired. The library falls back to the default evaluation behavior.
Unexpected garbage‑collection of the static license reference – in very long or memory‑intensive batches the JVM may reclaim the license object. Subsequent PDFs are opened without a valid license.

The watermark is stored as hidden text in the PDF; when you extract the document’s text that hidden text is returned together with the real content, often appearing garbled.

What to do next

  1. Load the license once, at application start, before any Aspose PDF code runs.
import com.aspose.pdf.License;
import java.io.InputStream;

public class AppInitializer {
static {
try (InputStream licStream = AppInitializer.class.getResourceAsStream("/Aspose.Pdf.lic")) {
if (licStream == null) {
throw new IllegalStateException("License file not found on classpath");
}
License license = new License();
license.setLicense(licStream);
} catch (Exception e) {
Log the error – without a license the library works in evaluation mode
e.printStackTrace();
}
}
}

Place Aspose.Pdf.lic in the classpath (e.g., src/main/resources).

  1. Ensure the license initialization runs in every class‑loader if you use multiple threads, servlet containers, or frameworks that create separate loaders (e.g., put the same code in a servlet init() method or a Spring @PostConstruct bean).

  2. Validate the license file

  • Open the .lic file with a text editor; it should contain a well‑formed XML block.
  • Verify that the license has not expired by checking the information on the Aspose customer portal.
  1. Use an absolute path only as a fallback (not recommended for production).
License license = new License();
license.setLicense("C:/licenses/Aspose.Pdf.lic");
  1. Consider updating to a newer Aspose.PDF for Java build if you are on an older version, as newer releases may contain improvements related to license initialization in multi‑threaded scenarios.

  2. Add logging around PDF loading to capture any license‑related or I/O problems:

try {
com.aspose.pdf.PdfDocument pdf = new com.aspose.pdf.PdfDocument("input.pdf");
} catch (Exception ex) {
logger.error("Failed to load PDF – check license initialization", ex);
}
  1. If the issue persists after the above steps, gather the following information for internal escalation:
  • The exact code snippet that opens the PDF.
  • Any stack trace or log entries produced when the “Evaluation Only” line appears.
  • The Aspose.PDF for Java version you are using.
  • Confirmation that the license file is accessible to the JVM process (file permissions, resolved path).

Collecting this data will allow the internal support team to reproduce the problem and determine whether additional configuration changes are required. Following the actions above should eliminate the intermittent “Evaluation Only” line from your extracted text.