List of usage examples for org.apache.pdfbox.pdmodel.common.filespecification PDFileSpecification getFile
public abstract String getFile();
From source file:org.apache.tika.parser.pdf.AbstractPDF2XHTML.java
License:Apache License
private void processDoc(String name, PDFileSpecification spec, AttributesImpl attributes) throws TikaException, SAXException, IOException { if (spec instanceof PDSimpleFileSpecification) { attributes.addAttribute("", "class", "class", "CDATA", "linked"); attributes.addAttribute("", "id", "id", "CDATA", spec.getFile()); xhtml.startElement("div", attributes); xhtml.endElement("div"); } else if (spec instanceof PDComplexFileSpecification) { if (attributes.getIndex("source") < 0) { attributes.addAttribute("", "source", "source", "CDATA", "attachment"); }/*from www . j a v a2 s . c o m*/ extractMultiOSPDEmbeddedFiles(name, (PDComplexFileSpecification) spec, attributes); } }
From source file:org.nuxeo.pdf.PDFLinks.java
License:Apache License
@SuppressWarnings("unchecked") protected ArrayList<LinkInfo> parseForLinks(String inSubType) throws IOException { PDActionRemoteGoTo goTo;/* www. j a v a 2 s . c o m*/ PDActionLaunch launch; PDActionURI uri; PDFileSpecification fspec; ArrayList<LinkInfo> li = new ArrayList<LinkInfo>(); List<PDPage> allPages; allPages = pdfDoc.getDocumentCatalog().getAllPages(); int pageNum = 0; for (PDPage page : allPages) { pageNum += 1; stripper.extractRegions(page); List<PDAnnotation> annotations = page.getAnnotations(); for (int j = 0; j < annotations.size(); j++) { PDAnnotation annot = annotations.get(j); if (annot instanceof PDAnnotationLink) { PDAnnotationLink link = (PDAnnotationLink) annot; PDAction action = link.getAction(); if (action.getSubType().equals(inSubType)) { String urlText = stripper.getTextForRegion("" + j); String urlValue = null; switch (inSubType) { case PDActionRemoteGoTo.SUB_TYPE: goTo = (PDActionRemoteGoTo) action; fspec = goTo.getFile(); urlValue = fspec.getFile(); break; case PDActionLaunch.SUB_TYPE: launch = (PDActionLaunch) action; fspec = launch.getFile(); urlValue = fspec.getFile(); break; case PDActionURI.SUB_TYPE: uri = (PDActionURI) action; urlValue = uri.getURI(); break; // . . . Others . . . } if (StringUtils.isNotBlank(urlValue)) { li.add(new LinkInfo(pageNum, inSubType, urlText, urlValue)); } } } } } return li; }