Subject: PdfTrueTypeFont constructor fails with "CreateProcess error=5, Access Denied" when running as a Windows Service (cmd.exe spawn blocked)
We're using Spire.PDF for Java version 11.6.2 on Windows. We ran into a startup failure when initializing PdfTrueTypeFont instances eagerly inside a Servlet's init() method (running under Apache Tomcat installed as a Windows Service, via Procrun, account = Local System).
Error observed:
class com.spire.pdf.packages.sprmyj: Fail to save. Saving of requested font type is not supported.
...
class com.spire.pdf.packages.sprjbw: Cannot run program "cmd.exe": CreateProcess error=5, Access Denied
---> java.io.IOException: Cannot run program "cmd.exe": CreateProcess error=5, Access Denied
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1170)
at java.base/java.lang.Runtime.exec(Runtime.java:366)
at com.spire.pdf.packages.sprjbw.spr...(Environment.java:362)
at com.spire.pdf.general.paper.drawing.ps.PsSystem.getWindowsFontsFolder(Unknown Source)
...
at com.spire.pdf.graphics.PdfTrueTypeFont.<init>(Unknown Source)
Root cause (confirmed from stack trace):
When constructing a PdfTrueTypeFont from a java.awt.Font instance (no explicit file path provided), Spire internally calls PsSystem.getWindowsFontsFolder(), which spawns an external cmd.exe process (via Runtime.exec) to determine the Windows fonts directory.
In our environment, the OS-level security policy / EDR blocks this specific service process from spawning cmd.exe, causing Runtime.exec to throw IOException: CreateProcess error=5, Access Denied, which Spire then wraps and propagates up, ultimately failing the PdfTrueTypeFont constructor entirely (no fallback).
Why this is a problem:
Spawning cmd.exe to resolve the Windows fonts folder is unnecessary — this information can be obtained without creating a child process (e.g. System.getenv("WINDIR"), registry access via JNA, or relying on java.awt.GraphicsEnvironment/font enumeration APIs that the JVM itself uses, which don't require spawning external processes).
Restricting child-process creation for Windows services is a standard, legitimate security hardening practice (enforced here by an EDR/AppLocker-type policy) — many enterprise/healthcare environments do this by default. A core PDF/font library shouldn't depend on the ability to spawn cmd.exe for basic font resolution.
There's no graceful fallback: when the cmd.exe spawn fails, the entire PdfTrueTypeFont construction fails hard instead of falling back to an alternative resolution method.
Environment:
Spire.PDF for Java: 11.6.2
JDK: 21.0.2
OS: Windows Server (Tomcat installed as Windows Service via Procrun, Local System account)
Reproduced with a minimal standalone test (no Tomcat, no other dependencies) running as a Windows Service under the same account — isolating the issue specifically to the cmd.exe spawn step in PdfTrueTypeFont initialization, not to our application code or to Tomcat/Servlet context. [se confermato domani: "and confirmed the failure reproduces identically in this isolated test"]
Request:
Could you confirm whether getWindowsFontsFolder() could be reimplemented without spawning cmd.exe, or whether a configuration option / fallback exists to avoid this child-process dependency? This would make the library usable in security-hardened Windows service environments where child process creation is restricted.
Happy to provide the full standalone reproduction project if useful.
Thanks!
PS: here a france link https://attack.mitre.org/techniques/T1190/