mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2026-04-16 23:08:38 +02:00
# Description of Changes Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing) for more details. Co-authored-by: a <a>
This commit is contained in:
@@ -91,6 +91,59 @@ public class GetInfoOnPDF {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates structured summary data about the PDF highlighting its unique characteristics such
|
||||
* as encryption status, permission restrictions, and standards compliance.
|
||||
*
|
||||
* @param document The PDF document to analyze
|
||||
* @return An ObjectNode containing structured summary data
|
||||
*/
|
||||
private ObjectNode generatePDFSummaryData(PDDocument document) {
|
||||
ObjectNode summaryData = objectMapper.createObjectNode();
|
||||
|
||||
// Check if encrypted
|
||||
if (document.isEncrypted()) {
|
||||
summaryData.put("encrypted", true);
|
||||
}
|
||||
|
||||
// Check permissions
|
||||
AccessPermission ap = document.getCurrentAccessPermission();
|
||||
ArrayNode restrictedPermissions = objectMapper.createArrayNode();
|
||||
|
||||
if (!ap.canAssembleDocument()) restrictedPermissions.add("document assembly");
|
||||
if (!ap.canExtractContent()) restrictedPermissions.add("content extraction");
|
||||
if (!ap.canExtractForAccessibility()) restrictedPermissions.add("accessibility extraction");
|
||||
if (!ap.canFillInForm()) restrictedPermissions.add("form filling");
|
||||
if (!ap.canModify()) restrictedPermissions.add("modification");
|
||||
if (!ap.canModifyAnnotations()) restrictedPermissions.add("annotation modification");
|
||||
if (!ap.canPrint()) restrictedPermissions.add("printing");
|
||||
|
||||
if (restrictedPermissions.size() > 0) {
|
||||
summaryData.set("restrictedPermissions", restrictedPermissions);
|
||||
summaryData.put("restrictedPermissionsCount", restrictedPermissions.size());
|
||||
}
|
||||
|
||||
// Check standard compliance
|
||||
if (checkForStandard(document, "PDF/A")) {
|
||||
summaryData.put("standardCompliance", "PDF/A");
|
||||
summaryData.put("standardPurpose", "long-term archiving");
|
||||
} else if (checkForStandard(document, "PDF/X")) {
|
||||
summaryData.put("standardCompliance", "PDF/X");
|
||||
summaryData.put("standardPurpose", "graphic exchange");
|
||||
} else if (checkForStandard(document, "PDF/UA")) {
|
||||
summaryData.put("standardCompliance", "PDF/UA");
|
||||
summaryData.put("standardPurpose", "universal accessibility");
|
||||
} else if (checkForStandard(document, "PDF/E")) {
|
||||
summaryData.put("standardCompliance", "PDF/E");
|
||||
summaryData.put("standardPurpose", "engineering workflows");
|
||||
} else if (checkForStandard(document, "PDF/VT")) {
|
||||
summaryData.put("standardCompliance", "PDF/VT");
|
||||
summaryData.put("standardPurpose", "variable and transactional printing");
|
||||
}
|
||||
|
||||
return summaryData;
|
||||
}
|
||||
|
||||
public static boolean checkForStandard(PDDocument document, String standardKeyword) {
|
||||
// Check XMP Metadata
|
||||
try {
|
||||
@@ -191,6 +244,12 @@ public class GetInfoOnPDF {
|
||||
}
|
||||
jsonOutput.set("FormFields", formFieldsNode);
|
||||
|
||||
// Generate structured summary data about PDF characteristics
|
||||
ObjectNode summaryData = generatePDFSummaryData(pdfBoxDoc);
|
||||
if (summaryData != null && summaryData.size() > 0) {
|
||||
jsonOutput.set("SummaryData", summaryData);
|
||||
}
|
||||
|
||||
// embeed files TODO size
|
||||
if (catalog.getNames() != null) {
|
||||
PDEmbeddedFilesNameTreeNode efTree = catalog.getNames().getEmbeddedFiles();
|
||||
|
||||
Reference in New Issue
Block a user