Example usage for com.lowagie.text Phrase Phrase

List of usage examples for com.lowagie.text Phrase Phrase

Introduction

In this page you can find the example usage for com.lowagie.text Phrase Phrase.

Prototype

private Phrase(boolean dummy) 

Source Link

Document

Constructs a Phrase that can be used in the static getInstance() method.

Usage

From source file:Agenda.java

public void preparaPDF(Object document) throws IOException, BadElementException, DocumentException {
    //criando novo pdf
    Document pdf = (Document) document;

    //abrindo documento
    pdf.open();//from  w  w  w  .j  a  v a2 s .co  m

    //modificando caracteristicas do documento
    pdf.setPageSize(PageSize.A4);

    //        //VERSAO FUNCIONAL    
    //        //criando paragrafo no texto
    //            Paragraph p = new Paragraph("Relatrio Contatos",            
    //            //editando configuracoes de fontes do texto
    //            FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD, new Color(255,150,255)));
    //            
    //        //definindo alinhamento
    //            p.setAlignment(Element.ALIGN_CENTER);
    //        
    //        //adiciona as modificaes ao documento
    //            pdf.add(p);

    //VERSAO CORRETA
    Paragraph p = new Paragraph();
    p.setFont(FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD, new Color(255, 255, 0)));
    p.add(new Phrase("Relatrio Contatos"));
    p.setAlignment(Element.ALIGN_CENTER);
    pdf.add(p);
}

From source file:ambit2.db.reporters.PDFReporter.java

public void header(Document output, Q query) {

    output.addCreationDate();//from   w w  w .  j a v  a 2 s. c om
    output.addCreator(getClass().getName());
    output.addSubject("");
    output.addAuthor("http://ambit.sourceforge.net");
    output.addHeader("License", getLicenseURI());
    output.addTitle(query.toString());
    output.addKeywords(query.toString());

    if (getLicenseURI() != null) {
        HeaderFooter footer = new HeaderFooter(new Phrase(String.format("License %s", getLicenseURI())), false);
        footer.setAlignment(Element.ALIGN_CENTER);
        output.setFooter(footer);
    }

    output.open();

    font = new Font(Font.TIMES_ROMAN, 10, Font.NORMAL);

    table = new PdfPTable(new float[] { 3f, 5f });
    table.setWidthPercentage(100);

    try {
        writeHeader(output);
    } catch (Exception x) {

    }

}

From source file:at.htlpinkafeld.beans.JahresuebersichtBean.java

/**
 * Factory-Method for a PdfCell/*from  ww w  .  j  a va 2  s  . c  om*/
 *
 * @param text Text for the cell
 * @param alignment alignment for the cell content
 * @return the created Cell
 */
private PdfPCell getCell(String text, int alignment) {
    PdfPCell cell = new PdfPCell(new Phrase(text));
    cell.setPadding(0);
    cell.setHorizontalAlignment(alignment);
    cell.setBorder(PdfPCell.NO_BORDER);
    return cell;
}

From source file:at.htlpinkafeld.beans.UserDetailsBean.java

private PdfPCell getCell(String text, int alignment) {
        PdfPCell cell = new PdfPCell(new Phrase(text));
        cell.setPadding(0);/*  ww  w .j a  v  a  2s  .c o m*/
        cell.setHorizontalAlignment(alignment);
        cell.setBorder(PdfPCell.NO_BORDER);
        return cell;
    }

From source file:beans.ReportsMB.java

public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException {
    if (null == selectedReport) {
        return;//from  w w  w  . ja  v  a  2  s  .  c  o  m
    }

    Document pdf = (Document) document;
    String documentTitle = getPDFraportTitle(selectedReport);
    pdf.addTitle(documentTitle);
    pdf.open();
    pdf.setPageSize(PageSize.A4);
    pdf.add(new Phrase(documentTitle));

}

From source file:biblivre3.administration.reports.AllUsersReport.java

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    AllUsersReportDto dto = (AllUsersReportDto) reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_ALL_USERS"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);/*from   w  ww .jav  a  2s . c o m*/
    document.add(new Phrase("\n"));
    Paragraph p2 = new Paragraph(this.getHeaderChunk(this.getText("REPORTS_ALL_USERS_TYPE_TOTALS")));
    p2.setAlignment(Paragraph.ALIGN_LEFT);
    document.add(p2);
    document.add(new Phrase("\n"));
    PdfPTable summaryTable = createSummaryTable(dto.getTypesMap());
    document.add(summaryTable);
    document.add(new Phrase("\n"));

    ArrayList<PdfPTable> listTable = createListTable(dto.getData());
    if (listTable != null) {
        Paragraph p3 = new Paragraph(this.getHeaderChunk(this.getText("REPORTS_ALL_USERS_TYPE_LIST")));
        p3.setAlignment(Paragraph.ALIGN_LEFT);
        document.add(p3);
        document.add(new Phrase("\n"));
        for (PdfPTable tabela : listTable) {
            document.add(tabela);
            document.add(new Phrase("\n"));
        }
    }
}

From source file:biblivre3.administration.reports.AssetHoldingByDateReport.java

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    AssetHoldingByDateDto dto = (AssetHoldingByDateDto) reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_ASSET_HOLDING_BY_DATE_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);/*from  ww w  .j  av  a2s .c o m*/
    document.add(new Phrase("\n"));
    PdfPTable table = new PdfPTable(8);
    table.setWidthPercentage(100f);
    createHeader(table);
    PdfPCell cell;
    List<String[]> dataList = dto.getData();
    for (String[] data : dataList) {
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[0])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[1])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[2])));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[3])));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[4])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[5])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
    }
    document.add(table);
}

From source file:biblivre3.administration.reports.AssetHoldingFullReport.java

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    AssetHoldingDto dto = (AssetHoldingDto) reportData;
    String title = "";
    if (this.topographic) {
        title = this.getText("REPORTS_TOPOGRAPHIC_TITLE");
    } else {//from ww  w .j a  v  a  2s .c  o m
        title = this.getText("REPORTS_ASSET_HOLDING_TITLE");
    }
    Paragraph p1 = new Paragraph(title);
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);
    document.add(new Phrase("\n"));
    PdfPTable table = new PdfPTable(20);
    table.setWidthPercentage(100f);
    createHeader(table);
    PdfPCell cell;
    List<String[]> dataList = dto.getData();
    Collections.sort(dataList, this);
    for (String[] data : dataList) {
        PdfContentByte cb = getWriter().getDirectContent();

        String holdingSerial = StringUtils.leftPad(data[0], 10, "0");
        Barcode39 code39 = new Barcode39();
        code39.setExtended(true);
        code39.setCode(holdingSerial);
        code39.setStartStopText(false);

        Image image39 = code39.createImageWithBarcode(cb, null, null);
        image39.scalePercent(100f);
        cell = new PdfPCell(new Paragraph(new Phrase(new Chunk(image39, 0, 0))));
        cell.setColspan(6);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[1])));
        cell.setColspan(3);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);

        Paragraph para = new Paragraph();
        para.add(new Phrase(this.getSmallFontChunk(data[2] + "\n")));
        para.add(new Phrase(this.getSmallFontChunk(data[3] + "\n")));

        if (StringUtils.isNotBlank(data[4])) {
            para.add(new Phrase(this.getBoldChunk(this.getText("REPORTS_LOCATION") + ": ")));
            para.add(new Phrase(this.getSmallFontChunk(data[4] + " ")));
        }

        if (StringUtils.isNotBlank(data[5])) {
            para.add(new Phrase(this.getBoldChunk(this.getText("REPORTS_EDITION") + ": ")));
            para.add(new Phrase(this.getSmallFontChunk(data[5] + " ")));
        }

        if (StringUtils.isNotBlank(data[6])) {
            para.add(new Phrase(this.getBoldChunk(this.getText("REPORTS_DATE") + ": ")));
            para.add(new Phrase(this.getSmallFontChunk(data[6])));
        }

        cell = new PdfPCell(para);
        cell.setColspan(11);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
        cell.setPaddingTop(5f);
        cell.setPaddingLeft(7f);
        cell.setPaddingBottom(4f);
        table.addCell(cell);
    }
    document.add(table);
}

From source file:biblivre3.administration.reports.AssetHoldingReport.java

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    AssetHoldingDto dto = (AssetHoldingDto) reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_ASSET_HOLDING_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);/*from w  ww .  jav  a  2s.  c o m*/
    document.add(new Phrase("\n"));
    PdfPTable table = new PdfPTable(7);
    table.setWidthPercentage(100f);
    createHeader(table);
    PdfPCell cell;
    List<String[]> dataList = dto.getData();
    Collections.sort(dataList, this);
    for (String[] data : dataList) {
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[0])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[1])));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[2])));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[3])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[4])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
    }
    document.add(table);
}

From source file:biblivre3.administration.reports.BibliographyReport.java

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    BibliographyReportDto dto = (BibliographyReportDto) reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_BIBLIOGRAPHY_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);// w  w w. j  a  va 2  s .com
    document.add(new Phrase("\n"));
    Paragraph p2 = new Paragraph(
            this.getHeaderChunk(this.getText("REPORTS_AUTHOR") + ":  " + dto.getAuthorName()));
    p2.setAlignment(Paragraph.ALIGN_LEFT);
    document.add(p2);
    document.add(new Phrase("\n"));
    if (dto.getData() != null) {
        PdfPTable table = new PdfPTable(8);
        table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
        createHeader(table);
        PdfPCell cell;
        for (String[] data : dto.getData()) {
            cell = new PdfPCell(new Paragraph(this.getNormalChunk(data[0])));
            cell.setColspan(3);
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);
            cell = new PdfPCell(new Paragraph(this.getNormalChunk(data[1])));
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);
            cell = new PdfPCell(new Paragraph(this.getNormalChunk(data[2])));
            cell.setColspan(2);
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);
            cell = new PdfPCell(new Paragraph(this.getNormalChunk(data[3])));
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);
            cell = new PdfPCell(new Paragraph(this.getNormalChunk(data[4])));
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);
        }
        document.add(table);
        document.add(new Phrase("\n"));
    }
}