if (names != null) PDEmbeddedFilesNameTreeNode embeddedFiles = names.getEmbeddedFiles(); if (embeddedFiles != 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")); } } }
private void extractEmbeddedDocuments(PDDocument document) throws IOException, SAXException, TikaException { PDDocumentNameDictionary namesDictionary = new PDDocumentNameDictionary(document.getDocumentCatalog()); PDEmbeddedFilesNameTreeNode efTree = namesDictionary.getEmbeddedFiles(); if (efTree == null) { return; } Map<String, PDComplexFileSpecification> embeddedFileNames = efTree.getNames(); //For now, try to get the embeddedFileNames out of embeddedFiles or its kids. //This code follows: pdfbox/examples/pdmodel/ExtractEmbeddedFiles.java //If there is a need we could add a fully recursive search to find a non-null //Map<String, COSObjectable> that contains the doc info. if (embeddedFileNames != null) { processEmbeddedDocNames(embeddedFileNames); } else { List<PDNameTreeNode<PDComplexFileSpecification>> kids = efTree.getKids(); if (kids == null) { return; } for (PDNameTreeNode<PDComplexFileSpecification> node : kids) { embeddedFileNames = node.getNames(); if (embeddedFileNames != null) { processEmbeddedDocNames(embeddedFileNames); } } } }
PDDocumentNameDictionary namesDictionary = new PDDocumentNameDictionary( document.getDocumentCatalog() ); PDEmbeddedFilesNameTreeNode efTree = namesDictionary.getEmbeddedFiles(); if (efTree != 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 sanitizeNamed(PDDocument doc, PDDocumentNameDictionary names) { if (names == null) { return; } new PDEmbeddedFileBleach(this, doc).sanitize(names.getEmbeddedFiles()); if (names.getJavaScript() != null) { recordJavascriptThreat("Named JavaScriptAction", "Action"); names.setJavascript(null); } }
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 namesDictionary = new PDDocumentNameDictionary( document.getDocumentCatalog() ); PDEmbeddedFilesNameTreeNode efTree = namesDictionary.getEmbeddedFiles(); if (efTree != null)
if (names != null) PDEmbeddedFilesNameTreeNode embeddedFiles = names.getEmbeddedFiles(); if (embeddedFiles != 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")); } } }
private void extractEmbeddedDocuments(PDDocument document) throws IOException, SAXException, TikaException { PDDocumentNameDictionary namesDictionary = new PDDocumentNameDictionary(document.getDocumentCatalog()); PDEmbeddedFilesNameTreeNode efTree = namesDictionary.getEmbeddedFiles(); if (efTree == null) { return; } Map<String, PDComplexFileSpecification> embeddedFileNames = efTree.getNames(); //For now, try to get the embeddedFileNames out of embeddedFiles or its kids. //This code follows: pdfbox/examples/pdmodel/ExtractEmbeddedFiles.java //If there is a need we could add a fully recursive search to find a non-null //Map<String, COSObjectable> that contains the doc info. if (embeddedFileNames != null) { processEmbeddedDocNames(embeddedFileNames); } else { List<PDNameTreeNode<PDComplexFileSpecification>> kids = efTree.getKids(); if (kids == null) { return; } for (PDNameTreeNode<PDComplexFileSpecification> node : kids) { embeddedFileNames = node.getNames(); if (embeddedFileNames != null) { processEmbeddedDocNames(embeddedFileNames); } } } }
private void extractEmbeddedDocuments(PDDocument document) throws IOException, SAXException, TikaException { PDDocumentNameDictionary namesDictionary = new PDDocumentNameDictionary(document.getDocumentCatalog()); PDEmbeddedFilesNameTreeNode efTree = namesDictionary.getEmbeddedFiles(); if (efTree == null) { return; } Map<String, PDComplexFileSpecification> embeddedFileNames = efTree.getNames(); //For now, try to get the embeddedFileNames out of embeddedFiles or its kids. //This code follows: pdfbox/examples/pdmodel/ExtractEmbeddedFiles.java //If there is a need we could add a fully recursive search to find a non-null //Map<String, COSObjectable> that contains the doc info. if (embeddedFileNames != null) { processEmbeddedDocNames(embeddedFileNames); } else { List<PDNameTreeNode<PDComplexFileSpecification>> kids = efTree.getKids(); if (kids == null) { return; } for (PDNameTreeNode<PDComplexFileSpecification> node : kids) { embeddedFileNames = node.getNames(); if (embeddedFileNames != null) { processEmbeddedDocNames(embeddedFileNames); } } } }
private void extractEmbeddedDocuments(PDDocument document) throws IOException, SAXException, TikaException { PDDocumentNameDictionary namesDictionary = new PDDocumentNameDictionary(document.getDocumentCatalog()); PDEmbeddedFilesNameTreeNode efTree = namesDictionary.getEmbeddedFiles(); if (efTree == null) { return; } Map<String, PDComplexFileSpecification> embeddedFileNames = efTree.getNames(); //For now, try to get the embeddedFileNames out of embeddedFiles or its kids. //This code follows: pdfbox/examples/pdmodel/ExtractEmbeddedFiles.java //If there is a need we could add a fully recursive search to find a non-null //Map<String, COSObjectable> that contains the doc info. if (embeddedFileNames != null) { processEmbeddedDocNames(embeddedFileNames); } else { List<PDNameTreeNode<PDComplexFileSpecification>> kids = efTree.getKids(); if (kids == null) { return; } for (PDNameTreeNode<PDComplexFileSpecification> node : kids) { embeddedFileNames = node.getNames(); if (embeddedFileNames != null) { processEmbeddedDocNames(embeddedFileNames); } } } }
PDDocumentNameDictionary namesDictionary = new PDDocumentNameDictionary( document.getDocumentCatalog() ); PDEmbeddedFilesNameTreeNode efTree = namesDictionary.getEmbeddedFiles(); if (efTree != null)
etn = names.getEmbeddedFiles(); if (etn == null) { return;
PDEmbeddedFilesNameTreeNode efTree = names.getEmbeddedFiles(); if (efTree == null) { efTree = new PDEmbeddedFilesNameTreeNode();
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); } }