private void handleWidget(PDAnnotationWidget widget) throws TikaException, SAXException, IOException { if (widget == null) { return; } handleDestinationOrAction(widget.getAction(), ActionTrigger.ANNOTATION_WIDGET); PDAnnotationAdditionalActions annotationActions = widget.getActions(); if (annotationActions != null) { handleDestinationOrAction(annotationActions.getBl(), ActionTrigger.ANNOTATION_LOSE_INPUT_FOCUS); handleDestinationOrAction(annotationActions.getD(), ActionTrigger.ANNOTATION_MOUSE_CLICK); handleDestinationOrAction(annotationActions.getE(), ActionTrigger.ANNOTATION_CURSOR_ENTERS); handleDestinationOrAction(annotationActions.getFo(), ActionTrigger.ANNOTATION_RECEIVES_FOCUS); handleDestinationOrAction(annotationActions.getPC(), ActionTrigger.ANNOTATION_PAGE_CLOSED); handleDestinationOrAction(annotationActions.getPI(), ActionTrigger.ANNOTATION_PAGE_NO_LONGER_VISIBLE); handleDestinationOrAction(annotationActions.getPO(), ActionTrigger.ANNOTATION_PAGE_OPENED); handleDestinationOrAction(annotationActions.getPV(), ActionTrigger.ANNOTATION_PAGE_VISIBLE); handleDestinationOrAction(annotationActions.getU(), ActionTrigger.ANNOTATION_MOUSE_RELEASED); handleDestinationOrAction(annotationActions.getX(), ActionTrigger.ANNOTATION_CURSOR_EXIT); } }
@Override protected void startDocument(PDDocument pdf) throws IOException { try { xhtml.startDocument(); handleDestinationOrAction(pdf.getDocumentCatalog().getOpenAction(), ActionTrigger.DOCUMENT_OPEN); } catch (TikaException|SAXException e) { throw new IOExceptionWithCause("Unable to start a document", e); } }
private void processAcroField(PDField field, final int currentRecursiveDepth) throws SAXException, IOException, TikaException { if (currentRecursiveDepth >= MAX_ACROFORM_RECURSIONS) { return; } PDFormFieldAdditionalActions pdFormFieldAdditionalActions = field.getActions(); if (pdFormFieldAdditionalActions != null) { handleDestinationOrAction(pdFormFieldAdditionalActions.getC(), ActionTrigger.FORM_FIELD_RECALCULATE); handleDestinationOrAction(pdFormFieldAdditionalActions.getF(), ActionTrigger.FORM_FIELD_FORMATTED); handleDestinationOrAction(pdFormFieldAdditionalActions.getK(), ActionTrigger.FORM_FIELD_KEYSTROKE); handleDestinationOrAction(pdFormFieldAdditionalActions.getV(), ActionTrigger.FORM_FIELD_VALUE_CHANGE); } if (field.getWidgets() != null) { for (PDAnnotationWidget widget : field.getWidgets()) { handleWidget(widget); } } addFieldString(field); if (field instanceof PDNonTerminalField) { int r = currentRecursiveDepth + 1; xhtml.startElement("ol"); for (PDField child : ((PDNonTerminalField)field).getChildren()) { processAcroField(child, r); } xhtml.endElement("ol"); } }
handleDestinationOrAction(additionalActions.getDP(), ActionTrigger.AFTER_DOCUMENT_PRINT); handleDestinationOrAction(additionalActions.getDS(), ActionTrigger.AFTER_DOCUMENT_SAVE); handleDestinationOrAction(additionalActions.getWC(), ActionTrigger.BEFORE_DOCUMENT_CLOSE); handleDestinationOrAction(additionalActions.getWP(), ActionTrigger.BEFORE_DOCUMENT_PRINT); handleDestinationOrAction(additionalActions.getWS(), ActionTrigger.BEFORE_DOCUMENT_SAVE); xhtml.endDocument(); } catch (TikaException e) {
void extractBookmarkText(PDOutlineNode bookmark) throws SAXException, IOException, TikaException { PDOutlineItem current = bookmark.getFirstChild(); if (current != null) { xhtml.startElement("ul"); while (current != null) { xhtml.startElement("li"); xhtml.characters(current.getTitle()); xhtml.endElement("li"); handleDestinationOrAction(current.getAction(), ActionTrigger.BOOKMARK); // Recurse: extractBookmarkText(current); current = current.getNextSibling(); } xhtml.endElement("ul"); } }
handleDestinationOrAction(pageActions.getC(), ActionTrigger.PAGE_CLOSE); handleDestinationOrAction(pageActions.getO(), ActionTrigger.PAGE_OPEN);