From c390f2111432794b0aa0f2d5b65646c8bda50393 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Mon, 15 Dec 2025 22:29:19 +0000 Subject: [PATCH] minor stuff --- .../service/PdfJsonFallbackFontService.java | 5 ++++- .../service/pdfjson/PdfJsonFontService.java | 19 +++++++++++++------ .../pdfjson/type3/Type3LibraryStrategy.java | 11 +++++++++-- .../type3/library/Type3FontLibrary.java | 12 ++++++++++-- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/app/core/src/main/java/stirling/software/SPDF/service/PdfJsonFallbackFontService.java b/app/core/src/main/java/stirling/software/SPDF/service/PdfJsonFallbackFontService.java index 1dd25fa0c..e4baee055 100644 --- a/app/core/src/main/java/stirling/software/SPDF/service/PdfJsonFallbackFontService.java +++ b/app/core/src/main/java/stirling/software/SPDF/service/PdfJsonFallbackFontService.java @@ -323,7 +323,10 @@ public class PdfJsonFallbackFontService { @jakarta.annotation.PostConstruct private void loadConfig() { - String configured = applicationProperties.getPdfEditor().getFallbackFont(); + String configured = null; + if (applicationProperties.getPdfEditor() != null) { + configured = applicationProperties.getPdfEditor().getFallbackFont(); + } if (configured != null && !configured.isBlank()) { fallbackFontLocation = configured; } else { diff --git a/app/core/src/main/java/stirling/software/SPDF/service/pdfjson/PdfJsonFontService.java b/app/core/src/main/java/stirling/software/SPDF/service/pdfjson/PdfJsonFontService.java index 85f3d5785..6a56bad09 100644 --- a/app/core/src/main/java/stirling/software/SPDF/service/pdfjson/PdfJsonFontService.java +++ b/app/core/src/main/java/stirling/software/SPDF/service/pdfjson/PdfJsonFontService.java @@ -72,12 +72,19 @@ public class PdfJsonFontService { } private void loadConfiguration() { - var cfg = applicationProperties.getPdfEditor().getCffConverter(); - this.cffConversionEnabled = cfg.isEnabled(); - this.cffConverterMethod = cfg.getMethod(); - this.pythonCommand = cfg.getPythonCommand(); - this.pythonScript = cfg.getPythonScript(); - this.fontforgeCommand = cfg.getFontforgeCommand(); + if (applicationProperties.getPdfEditor() != null + && applicationProperties.getPdfEditor().getCffConverter() != null) { + var cfg = applicationProperties.getPdfEditor().getCffConverter(); + this.cffConversionEnabled = cfg.isEnabled(); + this.cffConverterMethod = cfg.getMethod(); + this.pythonCommand = cfg.getPythonCommand(); + this.pythonScript = cfg.getPythonScript(); + this.fontforgeCommand = cfg.getFontforgeCommand(); + } else { + // Use defaults when config is not available + this.cffConversionEnabled = false; + log.warn("[FONT-DEBUG] PdfEditor configuration not available, CFF conversion disabled"); + } } public byte[] convertCffProgramToTrueType(byte[] fontBytes, String toUnicode) { diff --git a/app/core/src/main/java/stirling/software/SPDF/service/pdfjson/type3/Type3LibraryStrategy.java b/app/core/src/main/java/stirling/software/SPDF/service/pdfjson/type3/Type3LibraryStrategy.java index 5aac8cb9f..b4e8f9d95 100644 --- a/app/core/src/main/java/stirling/software/SPDF/service/pdfjson/type3/Type3LibraryStrategy.java +++ b/app/core/src/main/java/stirling/software/SPDF/service/pdfjson/type3/Type3LibraryStrategy.java @@ -43,8 +43,15 @@ public class Type3LibraryStrategy implements Type3ConversionStrategy { @jakarta.annotation.PostConstruct private void loadConfiguration() { - var cfg = applicationProperties.getPdfEditor().getType3().getLibrary(); - this.enabled = cfg.isEnabled(); + if (applicationProperties.getPdfEditor() != null + && applicationProperties.getPdfEditor().getType3() != null + && applicationProperties.getPdfEditor().getType3().getLibrary() != null) { + var cfg = applicationProperties.getPdfEditor().getType3().getLibrary(); + this.enabled = cfg.isEnabled(); + } else { + this.enabled = false; + log.warn("PdfEditor Type3 library configuration not available, disabled"); + } } @Override diff --git a/app/core/src/main/java/stirling/software/SPDF/service/pdfjson/type3/library/Type3FontLibrary.java b/app/core/src/main/java/stirling/software/SPDF/service/pdfjson/type3/library/Type3FontLibrary.java index 368866b7c..0fa1d2950 100644 --- a/app/core/src/main/java/stirling/software/SPDF/service/pdfjson/type3/library/Type3FontLibrary.java +++ b/app/core/src/main/java/stirling/software/SPDF/service/pdfjson/type3/library/Type3FontLibrary.java @@ -43,8 +43,16 @@ public class Type3FontLibrary { @jakarta.annotation.PostConstruct void initialise() { - this.indexLocation = - applicationProperties.getPdfEditor().getType3().getLibrary().getIndex(); + if (applicationProperties.getPdfEditor() != null + && applicationProperties.getPdfEditor().getType3() != null + && applicationProperties.getPdfEditor().getType3().getLibrary() != null) { + this.indexLocation = + applicationProperties.getPdfEditor().getType3().getLibrary().getIndex(); + } else { + log.warn("[TYPE3] PdfEditor Type3 library configuration not available; Type3 library disabled"); + entries = List.of(); + return; + } Resource resource = resourceLoader.getResource(indexLocation); if (!resource.exists()) { log.info("[TYPE3] Library index {} not found; Type3 library disabled", indexLocation);