PDDocumentNameDictionary names = catalog.getNames(); if (names != null)
/** * A Catalog shall not contain the EmbeddedFiles entry. * * @param ctx * @throws ValidationException */ protected void validateNames(PreflightContext ctx) throws ValidationException { PDDocumentNameDictionary names = catalog.getNames(); if (names != null) { PDEmbeddedFilesNameTreeNode efs = names.getEmbeddedFiles(); if (efs != null) { addValidationError(ctx, new ValidationError(ERROR_SYNTAX_TRAILER_CATALOG_EMBEDDEDFILES, "EmbeddedFile entry is present in the Names dictionary")); } if (names.getJavaScript() != null) { addValidationError(ctx, new ValidationError(ERROR_ACTION_FORBIDDEN_ACTIONS_NAMED, "Javascript entry is present in the Names dictionary")); } } }
PDDocumentNameDictionary namesDict = getNames(); if (namesDict != null)
PDDocument pd; File input = new File(inputfile); // Input File pd = PDDocument.load(input); //Writes all embedded Filenames (from pdf document) into Logfile try{ PDDocumentCatalog catalog = pd.getDocumentCatalog(); PDDocumentNameDictionary names = catalog.getNames(); PDEmbeddedFilesNameTreeNode embeddedFiles = names.getEmbeddedFiles(); Map<String, COSObjectable> embeddedFileNames = embeddedFiles.getNames(); //For-Each Loop is used to list all embedded files (if there is more than one) for (Map.Entry<String, COSObjectable> entry : embeddedFileNames.entrySet()) { //You might need to configure the logger first logger.info("Inputfile: " + inputfile +"Found embedded File: " + entry.getKey() + ":"); } } catch (Exception e){ System.out.println("Document has no attachments. "); }
private void reportEmbeddedFiles(PDDocumentCatalog catalog) { int index = 0; PDEmbeddedFilesNameTreeNode efTree = catalog.getNames().getEmbeddedFiles(); try { if (config.isFeatureEnabled(FeatureObjectType.EMBEDDED_FILE) && efTree.getNames() != null) { for (PDComplexFileSpecification file : efTree.getNames().values()) { reporter.report(PBFeaturesObjectCreator.createEmbeddedFileFeaturesObject(file, ++index)); } } } catch (IOException e) { LOGGER.debug("Error creating PDFBox SubType.", e); handleSubtypeCreationProblem(e.getMessage()); } if (efTree.getKids() != null) { for (PDNameTreeNode<PDComplexFileSpecification> tree : efTree.getKids()) { if (tree != null) { index = reportEmbeddedFileNode(tree, index); } } } }
PDDocumentNameDictionary names = catalog.getNames(); if (names != null)
/** * A Catalog shall not contain the EmbeddedFiles entry. * * @param ctx * @throws ValidationException */ protected void validateNames(PreflightContext ctx) throws ValidationException { PDDocumentNameDictionary names = catalog.getNames(); if (names != null) { PDEmbeddedFilesNameTreeNode efs = names.getEmbeddedFiles(); if (efs != null) { addValidationError(ctx, new ValidationError(ERROR_SYNTAX_TRAILER_CATALOG_EMBEDDEDFILES, "EmbeddedFile entry is present in the Names dictionary")); } if (names.getJavaScript() != null) { addValidationError(ctx, new ValidationError(ERROR_ACTION_FORBIDDEN_ACTIONS_NAMED, "Javascript entry is present in the Names dictionary")); } } }
/** * A Catalog shall not contain the EmbeddedFiles entry. * * @param ctx * @throws ValidationException */ protected void validateNames(PreflightContext ctx) throws ValidationException { PDDocumentNameDictionary names = catalog.getNames(); if (names != null) { PDEmbeddedFilesNameTreeNode efs = names.getEmbeddedFiles(); if (efs != null) { addValidationError(ctx, new ValidationError(ERROR_SYNTAX_TRAILER_CATALOG_EMBEDDEDFILES, "EmbeddedFile entry is present in the Names dictionary")); } if (names.getJavaScript() != null) { addValidationError(ctx, new ValidationError(ERROR_ACTION_FORBIDDEN_ACTIONS_NAMED, "Javascript entry is present in the Names dictionary")); } } }
PDDocumentNameDictionary namesDict = getNames(); if (namesDict != null)
PDDocumentNameDictionary namesDict = getNames(); if (namesDict != null)
private void getCatalogFeatures(PDDocumentCatalog catalog) { reporter.report(PBFeaturesObjectCreator.createMetadataFeaturesObject(catalog.getMetadata())); reporter.report(PBFeaturesObjectCreator.createOutlinesFeaturesObject(catalog.getDocumentOutline())); PDAcroForm acroForm = catalog.getAcroForm(); if (acroForm != null) { getAcroFormFeatures(acroForm); } if (catalog.getNames() != null && catalog.getNames().getEmbeddedFiles() != null) { reportEmbeddedFiles(catalog); } if (catalog.getOutputIntents() != null) { for (PDOutputIntent outInt : catalog.getOutputIntents()) { String iccProfileID = addICCProfileFromOutputIntent(outInt); if (!config.isFeatureEnabled(FeatureObjectType.ICCPROFILE)) { iccProfileID = null; } reporter.report(PBFeaturesObjectCreator.createOutputIntentFeaturesObject(outInt, iccProfileID)); } } PDPageTree pageTree = catalog.getPages(); if (pageTree != null) { getPageTreeFeatures(pageTree); } }
void sanitize(RandomAccessRead source, OutputStream outputStream) throws IOException, BleachException { final PDDocument doc = getDocument(source); final PDDocumentCatalog docCatalog = doc.getDocumentCatalog(); sanitizeNamed(doc, docCatalog.getNames()); PDDocumentCatalogBleach catalogBleach = new PDDocumentCatalogBleach(this); catalogBleach.sanitize(docCatalog); sanitizeDocumentOutline(doc.getDocumentCatalog().getDocumentOutline()); cosObjectBleach.sanitizeObjects(doc.getDocument().getObjects()); doc.save(outputStream); doc.close(); }