Ejemplo n.º 1
0
  /* (non-Javadoc)
   * @see de.offis.health.icardea.cied.pdf.interfaces.PDFExtractor#getBookmarkContentAsText()
   */
  @SuppressWarnings("unchecked")
  public java.util.List getBookmarkTitlesAsText() {
    java.util.List bookmarkContent = null;
    if (pdfReader != null) {
      // bookmarkContent = SimpleBookmark.getBookmark(pdfReader);

      PdfDictionary catalog = pdfReader.getCatalog();
      if (catalog != null) {
        PdfObject rootPdfObject = PdfReader.getPdfObjectRelease(catalog.get(PdfName.OUTLINES));
        if (rootPdfObject != null && rootPdfObject.isDictionary()) {
          PdfDictionary rootOutlinesPdfDictionary = (PdfDictionary) rootPdfObject;
          /*
           * If it doesn't exist create the List and populate it,
           * otherwise just return the already existing List.
           */
          if (bookmarkTextList == null) {
            bookmarkTextList = new ArrayList<String>();

            // Populate the List
            populateBookmarkTextList(rootOutlinesPdfDictionary, "");
          } // end if
        }
      } // end if
    }
    return bookmarkContent;
  }
Ejemplo n.º 2
0
 /**
  * Stores the next object of the XRef table. As soon as this method returns false, it makes no
  * longer sense calling it as all the objects have been stored.
  *
  * @return false if there are no objects left to check.
  */
 public boolean storeNextObject() {
   while (current < n) {
     current++;
     PdfObject object = reader.getPdfObjectRelease(current);
     if (object != null) {
       int idx = size();
       idxToRef.put(idx, current);
       refToIdx.put(current, idx);
       store(object);
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 3
0
  /**
   * This method will populate the text bookmark list.
   *
   * @param rootOutlinesPdfDictionary The node element for the bookmark item.
   * @param indentionString The base indention string to be used.
   */
  @SuppressWarnings("unchecked")
  private void populateBookmarkTextList(
      PdfDictionary rootOutlinesPdfDictionary, String indentionString) {
    PdfDictionary outlineItemPdfDictionary =
        (PdfDictionary) PdfReader.getPdfObjectRelease(rootOutlinesPdfDictionary.get(PdfName.FIRST));
    while (outlineItemPdfDictionary != null) {
      PdfString bookmarkTitle =
          (PdfString) PdfReader.getPdfObjectRelease(outlineItemPdfDictionary.get(PdfName.TITLE));
      bookmarkTextList.add(indentionString + bookmarkTitle.toUnicodeString());
      logger.trace(indentionString + bookmarkTitle.toUnicodeString());

      /*
       * Recursive call to fill List
       */
      populateBookmarkTextList(
          outlineItemPdfDictionary, indentionString + bookmarkIndentionString());

      /*
       * Get next outline item
       */
      outlineItemPdfDictionary =
          (PdfDictionary) PdfReader.getPdfObjectRelease(outlineItemPdfDictionary.get(PdfName.NEXT));
    } // end while
  }