Example #1
0
 /** @see com.lowagie.toolbox.AbstractTool#execute() */
 public void execute() {
   try {
     if (getValue("xmlfile") == null)
       throw new InstantiationException("You need to choose an xml file");
     if (getValue("pdffile") == null)
       throw new InstantiationException("You need to choose a source PDF file");
     PdfReader reader = new PdfReader(((File) getValue("pdffile")).getAbsolutePath());
     reader.consolidateNamedDestinations();
     List<HashMap<String, Object>> bookmarks = SimpleBookmark.getBookmark(reader);
     // save them in XML format
     FileOutputStream bmWriter = new FileOutputStream((File) getValue("xmlfile"));
     SimpleBookmark.exportToXML(bookmarks, bmWriter, "UTF-8", false);
     bmWriter.close();
   } catch (Exception e) {
     e.printStackTrace();
     JOptionPane.showMessageDialog(
         internalFrame, e.getMessage(), e.getClass().getName(), JOptionPane.ERROR_MESSAGE);
     System.err.println(e.getMessage());
   }
 }