Example usage for com.itextpdf.text Element ALIGN_BOTTOM

List of usage examples for com.itextpdf.text Element ALIGN_BOTTOM

Introduction

In this page you can find the example usage for com.itextpdf.text Element ALIGN_BOTTOM.

Prototype

int ALIGN_BOTTOM

To view the source code for com.itextpdf.text Element ALIGN_BOTTOM.

Click Source Link

Document

A possible value for vertical alignment.

Usage

From source file:gov.nih.nci.firebird.service.registration.AbstractPdfWriterGenerator.java

License:Open Source License

private void addColumnHeadingCell(PdfPTable table, String columnHeadingKey) {
    Paragraph contents = new Paragraph();
    contents.setAlignment(Element.ALIGN_BOTTOM);
    PdfPCell cell = createCell();/*w  w w . ja v  a 2 s .c  o  m*/
    cell.setBackgroundColor(TABLE_CELL_COLOR);
    cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell.setPhrase(contents);
    contents.add(getColumnHeaderChunk(columnHeadingKey));
    addToTable(table, cell);
}

From source file:gov.utah.dts.det.ccl.actions.trackingrecordscreening.letters.reports.LivescanAuthorization.java

private static PdfPTable getPage1WriteInLine1() throws BadElementException, DocumentException, Exception {
    PdfPTable table = new PdfPTable(2);
    PdfPTable dtl = null;/*from   ww  w.  j av  a2 s  .c o m*/

    int headerwidths[] = { 4, 96 }; // percentage
    table.setWidths(headerwidths); // percentage
    table.setWidthPercentage(100);
    table.setSpacingBefore(page1ListSpace);
    table.getDefaultCell().setPadding(0);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);

    // Redefine the headerwidths for the detail table
    headerwidths = new int[] { 25, 25, 25, 25 }; // percentage

    dtl = new PdfPTable(4);
    dtl.setWidths(headerwidths); // percentage
    dtl.setWidthPercentage(100);
    dtl.getDefaultCell().setLeading(fixedLeadingSmall, 0);
    dtl.getDefaultCell().setPadding(0);
    dtl.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    dtl.getDefaultCell().setVerticalAlignment(Element.ALIGN_BOTTOM);
    dtl.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    dtl.getDefaultCell().setCellEvent(new FloatingLinedPdfPCell());
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(SMALL_BLANK);
    table.addCell(SMALL_BLANK); // Leave first cell blank
    table.addCell(dtl);

    dtl = new PdfPTable(4);
    dtl.setWidths(headerwidths); // percentage
    dtl.setWidthPercentage(100);
    dtl.getDefaultCell().setLeading(fixedLeadingSmall, 0);
    dtl.getDefaultCell().setPadding(0);
    dtl.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    dtl.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);
    dtl.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    dtl.getDefaultCell().setCellEvent(new FloatingPdfPCell());
    dtl.addCell(new Phrase("Last Name", smallfont));
    dtl.addCell(new Phrase("Full First Name", smallfont));
    dtl.addCell(new Phrase("Full Middle Name", smallfont));
    dtl.addCell(new Phrase("AKA", smallfont));
    table.addCell(SMALL_BLANK); // Leave first cell blank
    table.addCell(dtl);

    dtl = new PdfPTable(4);
    dtl.getDefaultCell().setLeading(fixedLeadingSmall, 0);
    dtl.getDefaultCell().setPadding(0);
    dtl.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    dtl.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);
    dtl.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    dtl.getDefaultCell().setCellEvent(new FloatingPdfPCell());
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(new Phrase("If no middle name, write NA.", smallfont));
    dtl.addCell(SMALL_BLANK);
    table.addCell(SMALL_BLANK); // Leave first cell blank
    table.addCell(dtl);

    return table;
}

From source file:gov.utah.dts.det.ccl.actions.trackingrecordscreening.letters.reports.LivescanAuthorization.java

private static PdfPTable getPage1WriteInLine2() throws BadElementException, DocumentException, Exception {
    PdfPTable table = new PdfPTable(2);
    PdfPTable dtl = null;/*  ww w  .j  a v a 2s  . c  om*/
    PdfPCell cell = null;

    int headerwidths[] = { 4, 96 }; // percentage
    table.setWidths(headerwidths); // percentage
    table.setWidthPercentage(100);
    table.setSpacingBefore(page1ListSpace);
    table.getDefaultCell().setPadding(0);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);

    dtl = new PdfPTable(12);
    headerwidths = new int[] { 11, 5, 11, 5, 11, 5, 11, 5, 11, 5, 11, 9 }; // percentage
    dtl.setWidths(headerwidths); // percentage
    dtl.setWidthPercentage(100);
    dtl.getDefaultCell().setLeading(fixedLeadingSmall, 0);
    dtl.getDefaultCell().setPadding(0);
    dtl.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    dtl.getDefaultCell().setVerticalAlignment(Element.ALIGN_BOTTOM);
    dtl.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingLinedPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingLinedPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingLinedPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingLinedPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingLinedPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingLinedPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    table.addCell(SMALL_BLANK); // Leave first cell blank
    table.addCell(dtl);

    dtl = new PdfPTable(12);
    headerwidths = new int[] { 11, 5, 11, 5, 11, 5, 11, 5, 11, 5, 11, 9 }; // percentage
    dtl.setWidths(headerwidths); // percentage
    dtl.setWidthPercentage(100);
    dtl.getDefaultCell().setLeading(fixedLeadingSmall, 0);
    dtl.getDefaultCell().setPadding(0);
    dtl.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    dtl.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);
    dtl.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    dtl.getDefaultCell().setCellEvent(new FloatingPdfPCell());
    dtl.addCell(new Phrase("DOB", smallfont));
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(new Phrase("Eye Color", smallfont));
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(new Phrase("Hair Color", smallfont));
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(new Phrase("Weight", smallfont));
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(new Phrase("Height", smallfont));
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(new Phrase("Gender", smallfont));
    dtl.addCell(SMALL_BLANK);
    table.addCell(SMALL_BLANK); // Leave first cell blank
    table.addCell(dtl);

    return table;
}

From source file:gov.utah.dts.det.ccl.actions.trackingrecordscreening.letters.reports.LivescanAuthorization.java

private static PdfPTable getPage1WriteInLine3() throws BadElementException, DocumentException, Exception {
    PdfPTable table = new PdfPTable(2);
    PdfPTable dtl = null;//from w  w w  .  j  a  va2s .c o  m
    PdfPCell cell = null;

    int headerwidths[] = { 4, 96 }; // percentage
    table.setWidths(headerwidths); // percentage
    table.setWidthPercentage(100);
    table.setSpacingBefore(page1ListSpace);
    table.getDefaultCell().setPadding(0);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);

    dtl = new PdfPTable(7);
    headerwidths = new int[] { 24, 5, 21, 5, 16, 5, 24 }; // percentage
    dtl.setWidths(headerwidths); // percentage
    dtl.setWidthPercentage(100);
    dtl.getDefaultCell().setLeading(fixedLeadingSmall, 0);
    dtl.getDefaultCell().setPadding(0);
    dtl.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    dtl.getDefaultCell().setVerticalAlignment(Element.ALIGN_BOTTOM);
    dtl.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingLinedPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingLinedPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingLinedPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    cell = new PdfPCell(dtl.getDefaultCell());
    cell.setCellEvent(new FloatingLinedPdfPCell());
    cell.setPhrase(SMALL_BLANK);
    dtl.addCell(cell);
    table.addCell(SMALL_BLANK); // Leave first cell blank
    table.addCell(dtl);

    dtl = new PdfPTable(7);
    headerwidths = new int[] { 24, 5, 21, 5, 16, 5, 24 }; // percentage
    dtl.setWidths(headerwidths); // percentage
    dtl.setWidthPercentage(100);
    dtl.getDefaultCell().setLeading(fixedLeadingSmall, 0);
    dtl.getDefaultCell().setPadding(0);
    dtl.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    dtl.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);
    dtl.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    dtl.getDefaultCell().setCellEvent(new FloatingPdfPCell());
    dtl.addCell(new Phrase("Social Security Number", smallfont));
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(new Phrase("Place of Birth", smallfont));
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(new Phrase("Race", smallfont));
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(new Phrase("Country of Citizenship", smallfont));
    table.addCell(SMALL_BLANK); // Leave first cell blank
    table.addCell(dtl);

    return table;
}

From source file:gov.utah.dts.det.ccl.actions.trackingrecordscreening.letters.reports.LivescanAuthorization.java

private static PdfPTable getPage2HeaderTable() throws BadElementException, DocumentException, Exception {
    PdfPTable table = new PdfPTable(2);
    // format the tables
    int headerwidths[] = { 7, 93 }; // percentage
    table.setWidths(headerwidths); // percentage
    table.setWidthPercentage(100);/*from www  . jav a 2  s.  c o  m*/
    table.getDefaultCell().setLeading(fixedLeadingMedium, 0);
    table.getDefaultCell().setPadding(0);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_BOTTOM);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);

    return table;
}

From source file:jdbreport.model.io.pdf.itext5.ITextWriter.java

License:Apache License

protected int toPdfVAlignment(int verticalAlignment) {
    switch (verticalAlignment) {
    case CellStyle.TOP:
        return Element.ALIGN_TOP;
    case CellStyle.BOTTOM:
        return Element.ALIGN_BOTTOM;
    case CellStyle.CENTER:
        return Element.ALIGN_CENTER;
    }// ww w .jav  a2 s  .  c  om
    return Element.ALIGN_TOP;
}

From source file:nwk.com.br.documents.OrcamentoPdf.java

private PdfPTable dadosRodape(Orcamento orcamento) throws Exception {
    //tabela que pega com 100% do tamanho do arquivo, alinhada no centro com tres colunas e sem bordas
    PdfPTable rodape = new PdfPTable(new float[] { 0.5f, 0.2f, 0.3f });
    rodape.setWidthPercentage(100.0f);//seta o tamanho da tabela em relaao ao documento
    rodape.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    rodape.getDefaultCell().setBorder(0);

    PdfPCell obs = new PdfPCell(new Paragraph("\n\n Observaes:\n" + orcamento.getObservacoes(), f));
    PdfPCell ass = new PdfPCell(new Paragraph("\n\n_________________________\nAssinatura", f));

    Font fonteAviso = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLDITALIC);

    PdfPCell spc = new PdfPCell(new Paragraph(" "));
    PdfPCell aviso = new PdfPCell(new Paragraph(
            "AGRADEEMOS A PREFERNCIA\nORAMENTO VALIDO SOMENTE PARA O DIA DE SUA CRIAO!", fonteAviso));

    aviso.setHorizontalAlignment(Element.ALIGN_CENTER);
    obs.setHorizontalAlignment(Element.ALIGN_LEFT);
    ass.setHorizontalAlignment(Element.ALIGN_CENTER);

    obs.setBorder(0);/*from   ww w .ja  v a2 s.c o  m*/
    ass.setBorder(0);
    spc.setBorder(0);
    aviso.setBorder(0);

    spc.setColspan(3);
    aviso.setColspan(3);

    rodape.addCell(obs);
    rodape.addCell(new Paragraph(" "));
    rodape.addCell(ass);
    rodape.addCell(spc);
    rodape.addCell(spc);
    rodape.addCell(spc);
    rodape.addCell(spc);
    rodape.addCell(aviso);
    //rodape.setExtendLastRow(true);

    //cria uma nova celula que recebe a tabela anterior
    PdfPCell otherCell = new PdfPCell(rodape);
    otherCell.setBorder(0);
    otherCell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    otherCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    //cria uma nova tabela que recebe a celula otherCell
    PdfPTable rodape2 = new PdfPTable(new float[] { 1.0f });
    rodape2.setWidthPercentage(100.0f);//seta o tamanho da tabela em relaao ao documento

    rodape2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    rodape2.getDefaultCell().setBorder(0);

    //estende a tabela at o fim da pagina, como o alinhamento horizontal dela  bottom, ela fica toda no rodape
    rodape2.addCell(otherCell);
    rodape2.setExtendLastRow(true);

    return rodape2;
}

From source file:org.cejug.yougi.web.report.EventAttendeeReport.java

License:Open Source License

public void printReport(List<Attendee> attendees) throws DocumentException {
    float[] columnSizes = { 20, 220, 220, 60 };
    PdfPTable table = new PdfPTable(columnSizes.length);
    table.setLockedWidth(true);//from  w w  w .java 2  s  .c o  m
    table.setTotalWidth(columnSizes);

    PdfPCell headerCell = new PdfPCell(new Phrase("Yougi"));
    headerCell.setColspan(4);
    headerCell.setBackgroundColor(BaseColor.ORANGE);
    headerCell.setPadding(3);
    table.addCell(headerCell);

    table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);

    PdfPCell checkCell = new PdfPCell(new Phrase(" "));
    checkCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(checkCell);

    PdfPCell productCell = new PdfPCell(new Phrase("Nome"));
    productCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    productCell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    table.addCell(productCell);

    PdfPCell currentPurchaseCell = new PdfPCell(new Phrase("Email"));
    currentPurchaseCell.setPadding(3);
    currentPurchaseCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    currentPurchaseCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(currentPurchaseCell);

    PdfPCell previousPurchaseCell = new PdfPCell(new Phrase("Presente"));
    previousPurchaseCell.setPadding(3);
    previousPurchaseCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    previousPurchaseCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(previousPurchaseCell);

    table.getDefaultCell().setBackgroundColor(null);
    table.setHeaderRows(2);

    Font font = new Font(Font.FontFamily.HELVETICA, 9);
    int seq = 1;
    for (Attendee attendee : attendees) {
        table.addCell(new Phrase(String.valueOf(seq++), font));

        table.addCell(new Phrase(attendee.getUserAccount().getFullName(), font));

        table.addCell(new Phrase(attendee.getUserAccount().getEmail(), font));

        table.addCell(" ");
    }

    document.add(table);
}

From source file:org.ganttproject.impex.htmlpdf.itext.ThemeImpl.java

License:GNU General Public License

private PdfPTable createColontitleTable(String topLeft, String topRight, String bottomLeft,
        String bottomRight) {//from w  ww . j  av  a  2 s. c  om
    PdfPTable head = new PdfPTable(2);
    {
        PdfPCell cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        Paragraph p = new Paragraph(topLeft, getSansRegularBold(18));
        p.setAlignment(Paragraph.ALIGN_LEFT);
        // colontitle.setLeading(0);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
        // cell.setPaddingLeft(2);
        cell.setPaddingBottom(6);
        cell.setPhrase(p);
        head.addCell(cell);
    }
    {
        PdfPCell cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        Paragraph p = new Paragraph(topRight, getSansRegularBold(10));
        p.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cell.setPaddingBottom(6);
        cell.setPhrase(p);
        head.addCell(cell);
    }
    {
        PdfPCell cell = new PdfPCell();
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setPaddingLeft(3);
        cell.setPaddingTop(2);
        cell.setPaddingBottom(6);
        cell.setBorder(Rectangle.TOP);
        cell.setBorderWidthTop(2);
        cell.setBorderColor(SORTAVALA_GREEN);
        Paragraph p = new Paragraph(bottomLeft, getSansRegularBold(18));
        p.setAlignment(Paragraph.ALIGN_LEFT);
        p.setExtraParagraphSpace(0);
        p.setIndentationLeft(0);
        p.setSpacingBefore(0);
        cell.setPhrase(p);
        // cell.addElement(p);
        head.addCell(cell);
    }
    {
        PdfPCell cell = new PdfPCell();
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setPaddingTop(2);
        cell.setPaddingBottom(6);
        cell.setBorder(Rectangle.TOP);
        cell.setBorderWidthTop(2);
        cell.setBorderColor(SORTAVALA_GREEN);
        Paragraph p = new Paragraph(bottomRight, getSansRegularBold(10));
        p.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPhrase(p);
        head.addCell(cell);
    }
    final Document document = myDoc;
    Rectangle page = document.getPageSize();
    head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
    return head;
}

From source file:org.larz.dom4.editor.ReportGenerator.java

License:Open Source License

public static void generateReport(XtextEditor sourcePage, final Shell shell) {
    final IXtextDocument myDocument = ((XtextEditor) sourcePage).getDocument();
    myDocument.modify(new IUnitOfWork.Void<XtextResource>() {
        @Override//w w w .j  ava2 s  .c om
        public void process(XtextResource resource) throws Exception {
            Map<String, Map<String, ModObject>> cellMap = new HashMap<String, Map<String, ModObject>>();

            Dom4Mod dom4Mod = (Dom4Mod) resource.getContents().get(0);
            EList<AbstractElement> elements = dom4Mod.getElements();
            for (AbstractElement element : elements) {
                if (element instanceof SelectArmorById || element instanceof SelectArmorByName) {
                    String name = getSelectArmorname((Armor) element);
                    if (name == null)
                        continue;
                    String id = getArmorid((Armor) element);

                    Map<String, ModObject> map = cellMap.get(ARMOR);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(ARMOR, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Armor) element, modObject.propertyMap);
                } else if (element instanceof NewArmor) {
                    String name = getArmorname((Armor) element);
                    String id = getArmorid((Armor) element);

                    Map<String, ModObject> map = cellMap.get(ARMOR);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(ARMOR, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Armor) element, modObject.propertyMap);
                } else if (element instanceof SelectWeaponById || element instanceof SelectWeaponByName) {
                    String name = getSelectWeaponname((Weapon) element);
                    String id = getWeaponid((Weapon) element);

                    Map<String, ModObject> map = cellMap.get(WEAPONS);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(WEAPONS, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Weapon) element, modObject.propertyMap);
                } else if (element instanceof NewWeapon) {
                    String name = getWeaponname((Weapon) element);
                    String id = getWeaponid((Weapon) element);

                    Map<String, ModObject> map = cellMap.get(WEAPONS);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(WEAPONS, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Weapon) element, modObject.propertyMap);
                } else if (element instanceof SelectMonsterById || element instanceof SelectMonsterByName) {
                    String name = getSelectMonstername((Monster) element);
                    String id = getMonsterid((Monster) element);

                    Map<String, ModObject> map = cellMap.get(MONSTERS);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(MONSTERS, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Monster) element, modObject.propertyMap);
                } else if (element instanceof NewMonster) {
                    String name = getMonstername((Monster) element);
                    String id = getMonsterid((Monster) element);

                    Map<String, ModObject> map = cellMap.get(MONSTERS);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(MONSTERS, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Monster) element, modObject.propertyMap);
                } else if (element instanceof SelectSpellById || element instanceof SelectSpellByName) {
                    String name = getSelectSpellname((Spell) element);
                    String id = getSpellid((Spell) element);

                    Map<String, ModObject> map = cellMap.get(SPELLS);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(SPELLS, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Spell) element, modObject.propertyMap);
                } else if (element instanceof NewSpell) {
                    String name = getSpellname((Spell) element);
                    //String id = getSpellid((Spell)element);

                    Map<String, ModObject> map = cellMap.get(SPELLS);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(SPELLS, map);
                    }
                    ModObject modObject = map.get(name);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = "" + name;
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(name, modObject);
                    }
                    setPropertyValues((Spell) element, modObject.propertyMap);
                } else if (element instanceof SelectItemById || element instanceof SelectItemByName) {
                    String name = getSelectItemname((Item) element);
                    String id = getItemid((Item) element);

                    Map<String, ModObject> map = cellMap.get(ITEMS);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(ITEMS, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Item) element, modObject.propertyMap);
                } else if (element instanceof NewItem) {
                    String name = getItemname((Item) element);
                    //String id = getItemid((Item)element);

                    Map<String, ModObject> map = cellMap.get(ITEMS);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(ITEMS, map);
                    }
                    ModObject modObject = map.get(name);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name;
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(name, modObject);
                    }
                    setPropertyValues((Item) element, modObject.propertyMap);
                } else if (element instanceof SelectSiteById || element instanceof SelectSiteByName) {
                    String name = getSelectSitename((Site) element);
                    String id = getSiteid((Site) element);

                    Map<String, ModObject> map = cellMap.get(SITES);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(SITES, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Site) element, modObject.propertyMap);
                } else if (element instanceof NewSite) {
                    String name = getSitename((Site) element);
                    String id = getSiteid((Site) element);

                    Map<String, ModObject> map = cellMap.get(SITES);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(SITES, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Site) element, modObject.propertyMap);
                } else if (element instanceof SelectNation) {
                    //                  String name = getSelectNationname((Nation)element);
                    //                  String id = getNationid((Nation)element);
                    //
                    //                  Map<String, ModObject> map = cellMap.get(NATIONS);
                    //                  if (map == null) {
                    //                     map = new HashMap<String, ModObject>();
                    //                     cellMap.put(NATIONS, map);
                    //                  }
                    //                  ModObject modObject = map.get(id);
                    //                  if (modObject == null) {
                    //                     modObject = new ModObject();
                    //                     modObject.title = name + " (" + id + ")";
                    //                     modObject.propertyMap = new HashMap<String, PropertyValues>();
                    //                     map.put(id, modObject);
                    //                  }
                    //                  setPropertyValues((SelectNation)element, modObject.propertyMap, resource);
                }

            }

            try {
                // step 1
                Document document = new Document(PageSize.LETTER.rotate());
                // step 2
                File tempFile = File.createTempFile("dom4editor", ".pdf");
                tempFile.deleteOnExit();
                FileOutputStream tempFileOutputStream = new FileOutputStream(tempFile);

                PdfWriter.getInstance(document, tempFileOutputStream);
                // step 3
                document.open();

                List<Map.Entry<String, Map<String, ModObject>>> cellList = new ArrayList<Map.Entry<String, Map<String, ModObject>>>();
                for (Map.Entry<String, Map<String, ModObject>> innerEntry : cellMap.entrySet()) {
                    cellList.add(innerEntry);
                }
                Collections.sort(cellList, new Comparator<Map.Entry<String, Map<String, ModObject>>>() {
                    @Override
                    public int compare(Map.Entry<String, Map<String, ModObject>> o1,
                            Map.Entry<String, Map<String, ModObject>> o2) {
                        return o1.getKey().compareTo(o2.getKey());
                    }
                });

                for (Map.Entry<String, Map<String, ModObject>> entry : cellList) {
                    PdfPTable table = new PdfPTable(1);
                    table.setWidthPercentage(100f);

                    PdfPCell cell = new PdfPCell(new Phrase(entry.getKey(), TITLE));
                    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
                    cell.setFixedHeight(26f);
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
                    table.addCell(cell);
                    table.setHeaderRows(1);

                    List<Map.Entry<String, ModObject>> list = new ArrayList<Map.Entry<String, ModObject>>();
                    for (Map.Entry<String, ModObject> innerEntry : entry.getValue().entrySet()) {
                        list.add(innerEntry);
                    }

                    Collections.sort(list, new Comparator<Map.Entry<String, ModObject>>() {
                        @Override
                        public int compare(Map.Entry<String, ModObject> o1, Map.Entry<String, ModObject> o2) {
                            return o1.getValue().title.compareTo(o2.getValue().title);
                        }
                    });

                    PdfPTable propertyTable = null;
                    if (entry.getKey().equals(ARMOR)) {
                        propertyTable = getTable(new String[] { "name", "type", "prot", "def", "enc", "rcost" },
                                new String[] { "Name", "Type", "Prot", "Def", "Enc", "Rcost" },
                                new ValueTranslator[] { null, new ValueTranslator() {
                                    @Override
                                    public String translate(String value) {
                                        if (value == null)
                                            return null;
                                        if (value.equals("4"))
                                            return "Shield";
                                        if (value.equals("5"))
                                            return "Body Armor";
                                        if (value.equals("6"))
                                            return "Helmet";
                                        return "Unknown";
                                    }
                                }, null, null, null, null }, null, list);
                        propertyTable.setWidths(new float[] { 5, 1, 1, 1, 1, 1 });
                    }
                    if (entry.getKey().equals(WEAPONS)) {
                        propertyTable = getTable(
                                new String[] { "name", "dmg", "att", "nratt", "def", "len", "range", "ammo",
                                        "rcost" },
                                new String[] { "Name", "Dmg", "Att", "Nratt", "Def", "Len", "Range", "Ammo",
                                        "Rcost" },
                                null, null, list);
                        propertyTable.setWidths(new float[] { 5, 1, 1, 1, 1, 1, 1, 1, 1 });
                    }
                    if (entry.getKey().equals(MONSTERS)) {
                        propertyTable = getTable(
                                new String[] { "name", "hp", "prot", "MOVE", "size", "ressize", "str", "enc",
                                        "att", "def", "prec", "mr", "mor", "gcost", "rcost" },
                                new String[] { "Name", "HP", "Prot", "Move", "Size", "Rsize", "Str", "Enc",
                                        "Att", "Def", "Prec", "MR", "Mor", "Gcost", "Rcost" },
                                null, new ValueCombiner[] { null, null, null, new ValueCombiner() {
                                    @Override
                                    public String translate(String[] value) {
                                        if (value[0] == null && value[1] == null)
                                            return null;
                                        return value[0] + "/" + value[1];
                                    }

                                    @Override
                                    public String[] getNeededColumns() {
                                        return new String[] { "mapmove", "ap" };
                                    }
                                }, null, null, null, null, null, null, null, null, null, null, null }, list);
                        propertyTable.setWidths(new float[] { 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
                    }
                    if (entry.getKey().equals(ITEMS)) {
                        propertyTable = getTable(
                                new String[] { "name", "constlevel", "PATH", "type", "weapon", "armor" },
                                new String[] { "Name", "Constlevel", "Path Req", "Type", "Weapon", "Armor" },
                                new ValueTranslator[] { null, null, null, new ValueTranslator() {
                                    @Override
                                    public String translate(String value) {
                                        if (value == null)
                                            return null;
                                        if (value.equals("1"))
                                            return "1-h Weapon";
                                        if (value.equals("2"))
                                            return "2-h Weapon";
                                        if (value.equals("3"))
                                            return "Missile Weapon";
                                        if (value.equals("4"))
                                            return "Shield";
                                        if (value.equals("5"))
                                            return "Body Armor";
                                        if (value.equals("6"))
                                            return "Helmet";
                                        if (value.equals("7"))
                                            return "Boots";
                                        if (value.equals("8"))
                                            return "Misc";
                                        return "Unknown";
                                    }
                                }, null, null }, new ValueCombiner[] { null, null, new ValueCombiner() {
                                    @Override
                                    public String translate(String[] value) {
                                        if (value[0] == null && value[1] == null && value[2] == null
                                                && value[3] == null)
                                            return null;
                                        StringBuffer buf = new StringBuffer();
                                        if (value[0] != null && !value[0].equals("null")) {
                                            buf.append(getPathName(Integer.parseInt(value[0])) + value[1]);
                                        }
                                        if (value[2] != null && !value[2].equals("null")
                                                && !value[2].equals("-1")) {
                                            buf.append(getPathName(Integer.parseInt(value[2])) + value[3]);
                                        }
                                        return buf.toString();
                                    }

                                    @Override
                                    public String[] getNeededColumns() {
                                        return new String[] { "mainpath", "mainlevel", "secondarypath",
                                                "secondarylevel" };
                                    }
                                }, null, null, null }, list);
                        propertyTable.setWidths(new float[] { 2.5f, 1, 1, 1, 2.5f, 2.5f });
                    }
                    if (entry.getKey().equals(SPELLS)) {
                        propertyTable = getTable(
                                new String[] { "name", "school", "researchlevel", "aoe", "damage", "effect",
                                        "fatiguecost", "nreff", "range", "precision", "spec", "nextspell" },
                                new String[] { "Name", "School", "Research", "AOE", "Damage", "Effect",
                                        "Fatigue", "Nreff", "Range", "Precision", "Spec", "Nextspell" },
                                null, null, list);
                        propertyTable.setWidths(new float[] { 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
                    }
                    if (entry.getKey().equals(NATIONS)) {
                        propertyTable = getTable(new String[] { "name", "startsite1", "startsite2",
                                "startsite3", "startsite4", "era", "startfort" }, list);
                        propertyTable.setWidths(new float[] { 5, 1, 1, 1, 1, 1, 1 });
                    }
                    if (entry.getKey().equals(SITES)) {
                        propertyTable = getTable(
                                new String[] { "name", "path", "level", "rarity", "loc", "homemon", "homecom",
                                        "gold", "res" },
                                new String[] { "Name", "Path", "Level", "Rarity", "Loc", "Homemon", "Homecom",
                                        "Gold", "Res" },
                                new ValueTranslator[] { null, new ValueTranslator() {
                                    @Override
                                    public String translate(String value) {
                                        if (value == null)
                                            return null;
                                        if (value.equals("0"))
                                            return "Fire";
                                        if (value.equals("1"))
                                            return "Air";
                                        if (value.equals("2"))
                                            return "Water";
                                        if (value.equals("3"))
                                            return "Earth";
                                        if (value.equals("4"))
                                            return "Astral";
                                        if (value.equals("5"))
                                            return "Death";
                                        if (value.equals("6"))
                                            return "Nature";
                                        if (value.equals("7"))
                                            return "Blood";
                                        return "Unknown";
                                    }
                                }, null, null, null, null, null, null, null }, null, list);
                        propertyTable.setWidths(new float[] { 5, 1, 1, 1, 1, 1, 1, 1, 1 });
                    }
                    PdfPCell innerCell = new PdfPCell();
                    innerCell.addElement(propertyTable);
                    innerCell.setBorder(PdfPCell.NO_BORDER);
                    innerCell.setHorizontalAlignment(Element.ALIGN_LEFT);

                    table.addCell(innerCell);
                    document.add(table);
                    document.newPage();
                }
                document.close();

                tempFileOutputStream.flush();
                tempFileOutputStream.close();

                Program pdfViewer = Program.findProgram("pdf");
                if (pdfViewer != null) {
                    pdfViewer.execute(tempFile.getAbsolutePath());
                } else {
                    FileDialog dialog = new FileDialog(shell, SWT.SAVE);
                    dialog.setFilterExtensions(new String[] { "*.pdf" });
                    if (dialog.open() != null) {
                        FileInputStream from = null;
                        FileOutputStream to = null;
                        try {
                            String filterPath = dialog.getFilterPath();
                            String name = dialog.getFileName();

                            from = new FileInputStream(new File(tempFile.getAbsolutePath()));
                            to = new FileOutputStream(new File(filterPath + File.separator + name));
                            byte[] buffer = new byte[4096];
                            int bytesRead;

                            while ((bytesRead = from.read(buffer)) != -1) {
                                to.write(buffer, 0, bytesRead); // write
                            }
                        } finally {
                            if (from != null) {
                                from.close();
                            }
                            if (to != null) {
                                to.close();
                            }
                        }
                    }
                }

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