diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java b/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java index a167cb74..fea57764 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java @@ -260,23 +260,7 @@ public class GetInfoOnPDF { // Digital Signatures using iText7 TODO - - - - PDAcroForm pdAcroForm = pdfBoxDoc.getDocumentCatalog().getAcroForm(); - ArrayNode formFieldsArray2 = objectMapper.createArrayNode(); - if (pdAcroForm != null) { - - for (PDField field : pdAcroForm.getFields()) { - ObjectNode fieldNode = objectMapper.createObjectNode(); - fieldNode.put("FieldName", field.getFullyQualifiedName()); - fieldNode.put("FieldType", field.getFieldType()); - // Add more attributes as needed... - formFieldsArray2.add(fieldNode); - } - - } - jsonOutput.set("FormFields2", formFieldsArray2); + PDStructureTreeRoot structureTreeRoot = pdfBoxDoc.getDocumentCatalog().getStructureTreeRoot(); diff --git a/src/main/resources/templates/security/get-info-on-pdf.html b/src/main/resources/templates/security/get-info-on-pdf.html index dc93186c..a77b5ae6 100644 --- a/src/main/resources/templates/security/get-info-on-pdf.html +++ b/src/main/resources/templates/security/get-info-on-pdf.html @@ -5,7 +5,6 @@ -
@@ -71,14 +70,17 @@ function renderJsonSection(key, value, depth = 0) { + // Replace spaces and other non-alphanumeric characters with underscores for valid IDs + let safeKey = (typeof key === "string") ? key.replace(/[^a-zA-Z0-9]/g, '_') : key; + let output = `
-
+
`; // Check if the value is an object and has children - if (value && typeof value === 'object' && Object.keys(value).length) { + if (value && typeof value === 'object' && (Object.keys(value).length || Array.isArray(value))) { output += ` - `; } else { @@ -89,7 +91,7 @@ output += `
-
`; +
`; // Check if the value is a nested object if (typeof value === 'object' && !Array.isArray(value)) { @@ -99,9 +101,13 @@ } output += '
'; } else if (typeof value === 'object' && Array.isArray(value) && value.length) { // Array values + output += '
'; value.forEach((val, index) => { - output += renderJsonSection(index, val, depth + 1); + // For arrays, we're going to make the displayed key more descriptive. + const arrayKey = `${key}[${index}]`; + output += renderJsonSection(arrayKey, val, depth + 1); }); + output += '
'; } output += '
'; @@ -109,6 +115,8 @@ return output; } + +