List of usage examples for org.apache.pdfbox.pdmodel PDDocumentInformation getMetadataKeys
public Set<String> getMetadataKeys()
From source file:adams.flow.transformer.PDFMetaData.java
License:Open Source License
/** * Executes the flow item./*from www.j av a2s. c o m*/ * * @return null if everything is fine, otherwise error message */ @Override protected String doExecute() { String result; File file; SpreadSheet sheet; PDDocument document; PDDocumentInformation info; Row row; Set<String> keys; result = null; // get file if (m_InputToken.getPayload() instanceof File) file = (File) m_InputToken.getPayload(); else file = new PlaceholderFile((String) m_InputToken.getPayload()); sheet = new DefaultSpreadSheet(); sheet.setDataRowClass(SparseDataRow.class); sheet.setName("Meta-Data: " + file.getAbsolutePath()); try { row = sheet.addRow(); document = PDDocument.load(file.getAbsoluteFile()); info = document.getDocumentInformation(); addCell(row, "Title", info.getTitle()); addCell(row, "Subject", info.getSubject()); addCell(row, "Author", info.getAuthor()); addCell(row, "Keywords", info.getKeywords()); addCell(row, "Producer", info.getProducer()); addCell(row, "Creation Date", info.getCreationDate()); addCell(row, "Modification Date", info.getModificationDate()); addCell(row, "Creator", info.getCreator()); addCell(row, "Trapped", info.getTrapped()); keys = info.getMetadataKeys(); for (String key : keys) addCell(row, "Meta-" + key, info.getCustomMetadataValue(key)); } catch (Exception e) { result = handleException("Failed to extract meta-data: ", e); } if (result == null) m_OutputToken = new Token(sheet); return result; }
From source file:org.codelibs.fess.crawler.extractor.impl.PdfExtractor.java
License:Apache License
private void extractMetadata(final PDDocument document, final ExtractData extractData) { final PDDocumentInformation info = document.getDocumentInformation(); if (info == null) { return;//from w ww. j a v a 2s .com } for (final String key : info.getMetadataKeys()) { final String value = info.getCustomMetadataValue(key); addMetadata(extractData, key, value); } }
From source file:org.pdfmetamodifier.MetadataHelper.java
License:Apache License
/** * Convert Metadata object to list of lines. * /*from ww w . j a v a 2 s .com*/ * @param metadata * Source Metadata object. * @return list of lines with Metadata representation. */ public static List<String> metadataToLineList(final PDDocumentInformation documentInformation) { final List<String> lineList = new ArrayList<>(); if (documentInformation != null) { final List<String> matadataKeys = new ArrayList<>(documentInformation.getMetadataKeys()); Collections.sort(matadataKeys); for (String key : matadataKeys) { final String value = documentInformation.getCustomMetadataValue(key); if (value != null) { lineList.add(String.format(METADATA_LINE_TEMPLATE, key, value)); } } } return lineList; }