예제 #1
0
  /** Add indexes */
  private Document indexes() {

    // loop over indexes
    for (Iterator indexes = index2primary2secondary2elements.keySet().iterator();
        indexes.hasNext(); ) {

      String index = (String) indexes.next();
      Map primary2secondary2elements = (Map) index2primary2secondary2elements.get(index);

      // add section
      nextPage();
      startSection(index);
      push("block", "start-indent=1cm");

      // loop over primaries
      for (Iterator primaries = primary2secondary2elements.keySet().iterator();
          primaries.hasNext(); ) {

        String primary = (String) primaries.next();
        Map secondary2elements = (Map) primary2secondary2elements.get(primary);

        // add block and primary
        push("block", "");
        text(primary + " ", "");

        // loop over secondaries
        for (Iterator secondaries = secondary2elements.keySet().iterator();
            secondaries.hasNext(); ) {

          String secondary = (String) secondaries.next();
          List elements = (List) secondary2elements.get(secondary);

          if (secondary.length() > 0) {
            push("block", "start-indent=2cm"); // start-indent?
            text(secondary + " ", "");
          }

          // loop over elements
          for (int e = 0; e < elements.size(); e++) {
            if (e > 0) text(", ", "");
            Element element = (Element) elements.get(e);
            String id = element.getAttribute("id");

            push("basic-link", "internal-destination=" + id);
            push("page-number-citation", "ref-id=" + id);
            cursor.setAttributeNS(NS_GENJ, "genj:citation", Integer.toString(e + 1));
            pop();
            pop();
          }

          if (secondary.length() > 0) pop();
          // next
        }

        // next
        pop();
      }

      // next
      pop();
    }

    // done
    return this;
  }
예제 #2
0
  /** A test main */
  public static void main(String[] args) {

    try {

      Document doc = new Document("Testing FO");

      doc.addText("A paragraph");
      doc.nextParagraph("start-indent=10pt");
      doc.addText(
          "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. ");

      doc.nextParagraph("text-decoration=underline");
      doc.addText("this paragraph is underlined");

      doc.nextParagraph();
      doc.addText("this line contains ");
      doc.addText("underlined", "text-decoration=underline");
      doc.addText(" text");

      doc.startList();
      doc.nextListItem("genj:label=a)");
      doc.addText("A foo'd bullet");
      doc.nextListItem("genj:label=b)");
      doc.addText("A foo'd bullet");
      doc.nextListItem();
      doc.addText("A normal bullet");

      doc.addTOC();
      doc.startSection("Section 1");
      doc.addText("here comes a ")
          .addText("table", "font-weight=bold, color=rgb(255,0,0)")
          .addText(" for you:");
      doc.addImage(
          new File(
              "C:/Documents and Settings/Nils/My Documents/Java/Workspace/GenJ/gedcom/meiern.jpg"),
          "vertical-align=middle");
      doc.addImage(
          new File("C:/Documents and Settings/Nils/My Documents/My Pictures/usamap.gif"),
          "vertical-align=middle");

      //      doc.startTable("width=100%,border=0.5pt solid black,genj:csv=true");
      //      doc.addTableColumn("column-width=10%");
      //      doc.addTableColumn("column-width=10%");
      //      doc.addTableColumn("column-width=80%");
      //      doc.nextTableCell("color=red");
      //      doc.addText("AA");
      //      doc.nextTableCell();
      //      doc.addText("AB");
      //      doc.nextTableCell();
      //      //doc.addText("AC");
      //      doc.nextTableCell();
      //      doc.addText("BA"); // next row
      //      doc.nextTableCell("number-columns-spanned=2");
      //      doc.addText("BB+BC");
      //      doc.nextTableRow();
      //      doc.addText("CA");
      //      doc.nextTableCell();
      //      doc.addText("CB");
      //      doc.nextTableCell();
      //      doc.addText("CC");
      //      doc.endTable();
      //
      //      doc.startList();
      //      doc.nextListItem();
      //      doc.addText("Item 1");
      //      doc.addText(" with text talking about");
      //      doc.addIndexTerm("Animals", "Mammals");
      //      doc.addText(" elephants and ");
      //      doc.addIndexTerm("Animals", "Mammals", "Horse");
      //      doc.addText(" horses as well as ");
      //      doc.addIndexTerm("Animals", "Mammals", "Horse");
      //      doc.addText(" ponys and even ");
      //      doc.addIndexTerm("Animals", "Fish", "");
      //      doc.addText(" fish");
      //      doc.nextParagraph();
      //      doc.addText("and a newline");
      //      doc.nextListItem();
      //      doc.addText("Item 2");
      //      doc.startList();
      //      doc.addText("Item 2.1");
      //      doc.nextListItem();
      //      doc.addText("Item 2.2");
      //      doc.endList();
      //      doc.endList();
      //      doc.addText("Text");
      //
      doc.startSection("Section 2");
      doc.addText("Text and a page break");
      //      doc.nextPage();

      doc.addTOCEntry("Foo");

      doc.startSection("Section 3");
      doc.addText("Text");

      Format format;
      if (args.length > 0) format = Format.getFormat(args[0]);
      else format = new PDFFormat();

      File file = null;
      String ext = format.getFileExtension();
      if (ext != null) {
        file = new File("c:/temp/foo." + ext);
      }
      format.format(doc, file);

      if (file != null)
        Runtime.getRuntime()
            .exec(
                "c:/Program Files/Internet Explorer/iexplore.exe \""
                    + file.getAbsolutePath()
                    + "\"");

    } catch (IOException e) {
      e.printStackTrace();
    }
  }