Example usage for com.itextpdf.text Element ALIGN_LEFT

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

Introduction

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

Prototype

int ALIGN_LEFT

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

Click Source Link

Document

A possible value for paragraph alignment.

Usage

From source file:de.jost_net.JVerein.io.MitgliederStatistik.java

License:Open Source License

private void addBeitragsgruppe(Reporter reporter, Beitragsgruppe bg, Date stichtag) throws RemoteException {
    if (bg == null) {
        reporter.addColumn("Insgesamt", Element.ALIGN_LEFT);
    } else {//from w  w  w .ja  v  a2s .  c o  m
        reporter.addColumn(bg.getBezeichnung(), Element.ALIGN_LEFT);
    }
    reporter.addColumn(getBeitragsgruppe(bg, null, stichtag) + "", Element.ALIGN_RIGHT);
    reporter.addColumn(getBeitragsgruppe(bg, GeschlechtInput.MAENNLICH, stichtag) + "", Element.ALIGN_RIGHT);
    reporter.addColumn(getBeitragsgruppe(bg, GeschlechtInput.WEIBLICH, stichtag) + "", Element.ALIGN_RIGHT);
    reporter.addColumn(getBeitragsgruppe(bg, GeschlechtInput.OHNEANGABE, stichtag) + "", Element.ALIGN_RIGHT);
}

From source file:de.jost_net.JVerein.io.MitgliedschaftsjubilaeumExportPDF.java

License:Open Source License

@Override
protected void add(Mitglied m) throws RemoteException {
    reporter.addColumn(m.getEintritt(), Element.ALIGN_LEFT);
    reporter.addColumn(Adressaufbereitung.getNameVorname(m), Element.ALIGN_LEFT);
    reporter.addColumn(Adressaufbereitung.getAnschrift(m), Element.ALIGN_LEFT);
    String kommunikation = m.getTelefonprivat();
    if (kommunikation.length() > 0 && m.getTelefondienstlich().length() > 0) {
        kommunikation += ", ";
    }/* w ww. j  av a  2  s  .com*/
    kommunikation += m.getTelefondienstlich();

    if (kommunikation.length() > 0 && m.getEmail().length() > 0) {
        kommunikation += ", ";
    }
    kommunikation += m.getEmail();
    reporter.addColumn(kommunikation, Element.ALIGN_LEFT, false);
    anz++;
}

From source file:de.jost_net.JVerein.io.ProjektSaldoPDF.java

License:Open Source License

public ProjektSaldoPDF(ArrayList<ProjektSaldoZeile> zeile, final File file, Date datumvon, Date datumbis)
        throws ApplicationException {
    try {//from  ww  w.java2  s. co  m
        FileOutputStream fos = new FileOutputStream(file);
        String subtitle = new JVDateFormatTTMMJJJJ().format(datumvon) + " - "
                + new JVDateFormatTTMMJJJJ().format(datumbis);
        Reporter reporter = new Reporter(fos, "Projekte-Saldo", subtitle, zeile.size());
        makeHeader(reporter);

        for (ProjektSaldoZeile pz : zeile) {
            switch (pz.getStatus()) {
            case ProjektSaldoZeile.HEADER: {
                reporter.addColumn((String) pz.getAttribute("projektbezeichnung"), Element.ALIGN_LEFT,
                        new BaseColor(220, 220, 220), 4);
                break;
            }
            case ProjektSaldoZeile.DETAIL: {
                reporter.addColumn((String) pz.getAttribute("buchungsartbezeichnung"), Element.ALIGN_LEFT);
                reporter.addColumn((Double) pz.getAttribute("einnahmen"));
                reporter.addColumn((Double) pz.getAttribute("ausgaben"));
                reporter.addColumn((Double) pz.getAttribute("umbuchungen"));
                break;
            }
            case ProjektSaldoZeile.SALDOFOOTER: {
                reporter.addColumn((String) pz.getAttribute("projektbezeichnung"), Element.ALIGN_RIGHT);
                reporter.addColumn((Double) pz.getAttribute("einnahmen"));
                reporter.addColumn((Double) pz.getAttribute("ausgaben"));
                reporter.addColumn((Double) pz.getAttribute("umbuchungen"));
                break;
            }
            case ProjektSaldoZeile.SALDOGEWINNVERLUST: {
                reporter.addColumn((String) pz.getAttribute("projektbezeichnung"), Element.ALIGN_RIGHT);
                reporter.addColumn((Double) pz.getAttribute("einnahmen"));
                reporter.addColumn("", Element.ALIGN_LEFT, 2);
                break;
            }
            case ProjektSaldoZeile.GESAMTSALDOFOOTER: {
                reporter.addColumn((String) pz.getAttribute("projektbezeichnung"), Element.ALIGN_LEFT);
                reporter.addColumn((Double) pz.getAttribute("einnahmen"));
                reporter.addColumn((Double) pz.getAttribute("ausgaben"));
                reporter.addColumn((Double) pz.getAttribute("umbuchungen"));
                break;
            }
            case ProjektSaldoZeile.GESAMTSALDOGEWINNVERLUST: {
                reporter.addColumn((String) pz.getAttribute("projektbezeichnung"), Element.ALIGN_LEFT);
                reporter.addColumn((Double) pz.getAttribute("einnahmen"));
                reporter.addColumn("", Element.ALIGN_LEFT, 2);
                break;
            }
            case ProjektSaldoZeile.NICHTZUGEORDNETEBUCHUNGEN: {
                reporter.addColumn((String) pz.getAttribute("projektbezeichnung"), Element.ALIGN_RIGHT, 4);
                break;
            }
            }
        }
        GUI.getStatusBar().setSuccessText("Auswertung fertig.");
        reporter.closeTable();
        reporter.close();
        fos.close();
        FileViewer.show(file);
    } catch (Exception e) {
        Logger.error("error while creating report", e);
        throw new ApplicationException("Fehler", e);
    }
}

From source file:de.jost_net.JVerein.io.Reporter.java

License:Open Source License

public void add(String text, int size) throws DocumentException {
    Paragraph p = new Paragraph(text, getFreeSansBold(size));
    p.setAlignment(Element.ALIGN_LEFT);
    rpt.add(p);//from www. j  a  va  2 s  .  co  m
}

From source file:de.jost_net.JVerein.io.Reporter.java

License:Open Source License

/**
 * Fuegt eine neue Zelle zur Tabelle hinzu.
 *//*ww  w  . j  av a2s  .c o  m*/
public void addColumn(Double value) {
    if (value != null) {
        addColumn(getDetailCell(value.doubleValue()));
    } else {
        addColumn(getDetailCell("", Element.ALIGN_LEFT, false));
    }
}

From source file:de.jost_net.JVerein.io.Reporter.java

License:Open Source License

/**
 * Fuegt eine neue Zelle zur Tabelle hinzu.
 *//*from   w w w.j a v a 2  s  .c om*/
public void addColumn(Date value, int align) {
    if (value != null) {
        addColumn(getDetailCell(value, align));
    } else {
        addColumn("", Element.ALIGN_LEFT, false);
    }
}

From source file:de.jost_net.JVerein.io.Reporter.java

License:Open Source License

/**
 * Erzeugt den Tabellen-Header mit 100 % Breite.
 * //  ww w . j a  va  2s.com
 * @throws DocumentException
 */
public void createHeader() throws DocumentException {
    createHeader(100f, Element.ALIGN_LEFT);
}

From source file:de.jost_net.JVerein.io.Reporter.java

License:Open Source License

/**
 * Erzeugt eine Zelle fuer das uebergebene Datum.
 * //from   ww  w  .j  ava  2s. co m
 * @param value
 *          das Datum.
 * @return die erzeugte Zelle.
 */
private PdfPCell getDetailCell(Date value, int align) {
    if (value.equals(Einstellungen.NODATE)) {
        return getDetailCell("", Element.ALIGN_LEFT, false);
    }
    SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
    return getDetailCell(sdf.format(value), align, false);
}

From source file:de.jost_net.JVerein.io.StatistikJahrgaengeExportPDF.java

License:Open Source License

@Override
protected void open() throws DocumentException, FileNotFoundException {
    fos = new FileOutputStream(file);
    reporter = new Reporter(fos,
            "Statistik Jahrgnge, Stichtag: " + new JVDateFormatTTMMJJJJ().format(stichtag) + "", "", 3);
    reporter.addHeaderColumn("Jahrgang", Element.ALIGN_CENTER, 50, BaseColor.LIGHT_GRAY);
    reporter.addHeaderColumn("Insgesamt", Element.ALIGN_CENTER, 50, BaseColor.LIGHT_GRAY);
    reporter.addHeaderColumn("mnnlich", Element.ALIGN_CENTER, 50, BaseColor.LIGHT_GRAY);
    reporter.addHeaderColumn("weiblich", Element.ALIGN_CENTER, 50, BaseColor.LIGHT_GRAY);
    reporter.addHeaderColumn("ohne Angabe", Element.ALIGN_CENTER, 50, BaseColor.LIGHT_GRAY);
    reporter.createHeader(50, Element.ALIGN_LEFT);
    int summegesamt = 0;
    int summemaennlich = 0;
    int summeweiblich = 0;
    int summeohne = 0;
    for (String key : statistik.keySet()) {
        reporter.addColumn(key, Element.ALIGN_CENTER);
        StatistikJahrgang dsbj = statistik.get(key);
        reporter.addColumn(Einstellungen.INTFORMAT.format(dsbj.getAnzahlgesamt()), Element.ALIGN_RIGHT);
        reporter.addColumn(Einstellungen.INTFORMAT.format(dsbj.getAnzahlmaennlich()), Element.ALIGN_RIGHT);
        reporter.addColumn(Einstellungen.INTFORMAT.format(dsbj.getAnzahlweiblich()), Element.ALIGN_RIGHT);
        reporter.addColumn(Einstellungen.INTFORMAT.format(dsbj.getAnzahlOhne()), Element.ALIGN_RIGHT);
        summegesamt += dsbj.getAnzahlgesamt();
        summemaennlich += dsbj.getAnzahlmaennlich();
        summeweiblich += dsbj.getAnzahlweiblich();
        summeohne += dsbj.getAnzahlOhne();
    }/*from w  ww.  j  av  a2s  .  c  om*/
    reporter.addColumn("Summe", Element.ALIGN_CENTER);
    reporter.addColumn(Einstellungen.INTFORMAT.format(summegesamt), Element.ALIGN_RIGHT);
    reporter.addColumn(Einstellungen.INTFORMAT.format(summemaennlich), Element.ALIGN_RIGHT);
    reporter.addColumn(Einstellungen.INTFORMAT.format(summeweiblich), Element.ALIGN_RIGHT);
    reporter.addColumn(Einstellungen.INTFORMAT.format(summeohne), Element.ALIGN_RIGHT);
    reporter.closeTable();

}

From source file:edu.clemson.lph.pdfgen.PDFGen.java

License:Open Source License

private void printDoc() {
    if (sSourceFile == null || osDest == null) {
        logger.error("Cannot print nothing");
        return;//from   ww w . ja va2s. c om
    }
    boolean bBold = false;
    boolean bCenter = false;
    boolean bItalic = false;
    boolean bSmallItalic = false;
    boolean bUnderline = false;
    try {
        Document doc = new Document();
        float fCorr = doc.getPageSize().getWidth() / 8.5f;
        doc.setMargins(1.0f * fCorr, 1.0f * fCorr, 1.0f * fCorr, 1.0f * fCorr);

        PdfWriter.getInstance(doc, osDest);
        doc.open();
        BufferedReader br = new BufferedReader(new FileReader(sSourceFile));
        String sLine = br.readLine();
        while (sLine != null) {
            bBold = false;
            bCenter = false;
            if (sLine.startsWith(".")) {
                String sRest = sLine.substring(1);
                String sCodes = sRest.substring(0, sRest.indexOf('.'));
                sLine = sRest.substring(sRest.indexOf('.') + 1);
                if ("image".equals(sCodes)) {
                    String sFileName = sLine;
                    com.itextpdf.text.Image image = com.itextpdf.text.Image.getInstance(sFileName);
                    image.setAlignment(Element.ALIGN_CENTER);
                    doc.add(image);
                    sLine = br.readLine();
                    continue;
                } else if ("himage".equals(sCodes)) {
                    String sFileName = sLine;
                    com.itextpdf.text.Image image = com.itextpdf.text.Image.getInstance(sFileName);
                    image.scaleToFit(500, 40);
                    image.setAlignment(Element.ALIGN_CENTER);
                    doc.add(image);
                    Paragraph p = new Paragraph(" ");
                    doc.add(p);
                    sLine = br.readLine();
                    continue;
                } else if ("fimage".equals(sCodes)) {
                    int iBlanks = 9; // How do I figure out how many to get to end?
                    for (int i = 0; i < iBlanks; i++) {
                        Paragraph p = new Paragraph(" ");
                        doc.add(p);
                    }
                    String sFileName = sLine;
                    com.itextpdf.text.Image image = com.itextpdf.text.Image.getInstance(sFileName);
                    image.scaleToFit(500, 40);
                    image.setAlignment(Element.ALIGN_CENTER);
                    doc.add(image);
                    sLine = br.readLine();
                    continue;
                } else if ("list".equals(sCodes)) {
                    String sFullLine = doSub(sLine);
                    StringTokenizer tok = new StringTokenizer(sFullLine, "\n");
                    List list = new List(List.UNORDERED);
                    while (tok.hasMoreTokens()) {
                        String sNextLine = tok.nextToken();
                        ListItem listItem = new ListItem(sNextLine, fNormal);
                        list.add(listItem);
                    }
                    doc.add(list);
                    sLine = br.readLine();
                    continue;
                }
                if (sCodes.contains("b"))
                    bBold = true;
                if (sCodes.contains("c"))
                    bCenter = true;
                if (sCodes.contains("i"))
                    bItalic = true;
                if (sCodes.contains("si"))
                    bSmallItalic = true;
                if (sCodes.contains("u"))
                    bUnderline = true;
            }
            if (sLine.trim().length() == 0)
                sLine = " ";

            String sFullLine = doSub(sLine);
            Paragraph p = new Paragraph();
            if (bBold)
                p.setFont(fBold);
            else if (bSmallItalic)
                p.setFont(fSmallItalic);
            else if (bItalic)
                p.setFont(fItalic);
            else if (bUnderline)
                p.setFont(fUnderline);
            else
                p.setFont(fNormal);
            if (bCenter) {
                p.setAlignment(Element.ALIGN_CENTER);
            } else {
                p.setAlignment(Element.ALIGN_LEFT);
            }
            p.add(sFullLine);
            doc.add(p);
            sLine = br.readLine();
        }
        br.close();
        doc.close();
    } catch (FileNotFoundException e) {
        logger.error("Could not find source file " + sSourceFile + " or destination", e);
    } catch (IOException e) {
        logger.error("Could not read file " + sSourceFile, e);
    } catch (DocumentException e) {
        logger.error("Error creating iText Document", e);
    }
}