Example usage for com.lowagie.text Chunk NEWLINE

List of usage examples for com.lowagie.text Chunk NEWLINE

Introduction

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

Prototype

Chunk NEWLINE

To view the source code for com.lowagie.text Chunk NEWLINE.

Click Source Link

Document

This is a Chunk containing a newline.

Usage

From source file:util.ImprimirCIPDF.java

@Override
protected void gerarConteudo() throws Exception {

    ci = ComunicacaoInternaDAO.getInstance().selectFromId(ci.getId());

    Paragraph paragrafo = new Paragraph(ci.getTipoCI() + " - " + ci.getNumeroCI(), fonteH1);
    paragrafo.setAlignment(Element.ALIGN_CENTER);
    paragrafo.setSpacingBefore(10f);/*from  w w w .  jav  a2  s.  com*/
    documento.add(paragrafo);
    documento.add(Chunk.NEWLINE);
    documento.add(Chunk.NEWLINE);

    //1- DADOS DO ATENDIMENTO
    //documento.add(new Phrase("De: " + ci.getUo().getNome() + "                     Nmero: " + ci.getNumeroCI(), fonteB));
    documento.add(new Phrase("De: " + ci.getUo().getNome(), fonteB));
    documento.add(Chunk.NEWLINE);

    //Tipo Atendimento:
    if (ci.getDespachoList().get(0).getPara() != null) {
        documento.add(new Phrase("Para: " + ci.getDespachoList().get(0).getPara().getNome(), fonteB));
        documento.add(Chunk.NEWLINE);
    }

    if (!ci.getDespachoList().get(0).getDespachoCopiaList().isEmpty()) {
        StringBuffer strBuffer = new StringBuffer();
        for (DespachoCopia dc : ci.getDespachoList().get(0).getDespachoCopiaList()) {
            strBuffer.append(TratamentoString.tratarEspacosEmBranco(dc.getUnidadeOrganizacional().getNome()));
            strBuffer.append(", ");

        }
        documento.add(new Phrase("CC: " + strBuffer.toString(), fonteB));
        documento.add(Chunk.NEWLINE);

    }
    documento.add(Chunk.NEWLINE);

    documento.add(new Phrase("Assunto: " + ci.getAssunto(), fonteB));
    documento.add(Chunk.NEWLINE);
    documento.add(new Phrase("        ", fonte));
    documento.add(Chunk.NEWLINE);

    gerarLinhaHR();

    documento.add(Chunk.NEWLINE);

    documento.add(Chunk.NEWLINE);

    StringReader strReader = new StringReader(ci.getDespachoList().get(0).getConteudo());
    ArrayList p = new ArrayList();
    p = HTMLWorker.parseToList(strReader, null);

    for (int i = 0; i < p.size(); i++) {

        documento.add(((Element) p.get(i)));
    }

    documento.add(Chunk.NEWLINE);
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");

    documento.add(new Phrase("Em: " + formatter.format(ci.getData()), fonteB));

    if (ci.getDespachoList().size() > 1) {
        documento.add(Chunk.NEXTPAGE);
        documento.add(Chunk.NEWLINE);
        this.gerarCabecalho();
        documento.add(Chunk.NEWLINE);
        Paragraph despachos = new Paragraph("Despachos", fonteH1);
        despachos.setAlignment(Element.ALIGN_CENTER);
        despachos.setSpacingBefore(10f);
        documento.add(despachos);
        documento.add(Chunk.NEWLINE);
        for (int i = 1; i < ci.getDespachoList().size(); i++) {
            gerarLinhaHR();
            documento.add(Chunk.NEWLINE);
            documento.add(new Phrase(
                    TratamentoString.tratarEspacosEmBranco(ci.getDespachoList().get(i - 1).getPara().getNome())
                            + " "
                            + TratamentoString
                                    .tratarEspacosEmBranco(ci.getDespachoList().get(i).getStatusString()),
                    fonteB));
            documento.add(Chunk.NEWLINE);
            documento.add(new Phrase("Observao: ", fonteB));
            strReader = new StringReader(ci.getDespachoList().get(i).getConteudo());
            p = HTMLWorker.parseToList(strReader, null);
            for (int j = 0; j < p.size(); j++) {

                documento.add(((Element) p.get(j)));
            }
            gerarLinhaHR();
            documento.add(Chunk.NEWLINE);

        }
    }

}

From source file:util.PDFconverter.java

public static void createPDF(String[] header, String[][] data, String path, String tittle,
        float[] columnWidths) {
    try {// w  w w .ja  v a 2s  .c  om
        Document doc = new Document();

        PdfWriter.getInstance(doc, new FileOutputStream(path));

        doc.open();
        doc.setPageSize(PageSize.A4);
        doc.setMargins(10, 10, 10, 10);
        Font litle = new Font(Font.COURIER, 7, Font.NORMAL);
        Font norm = new Font(Font.TIMES_ROMAN, 8, Font.NORMAL);
        Font normBold = new Font(Font.TIMES_ROMAN, 8, Font.BOLD);
        Font TitleFont = new Font(Font.TIMES_ROMAN, 12, Font.BOLD);

        doc.add(Chunk.NEWLINE);
        Paragraph judul = new Paragraph(tittle, TitleFont);
        judul.setAlignment(Element.ALIGN_CENTER);
        doc.add(judul);

        //          Paragraph tgl = new Paragraph("tanggal " + tanggal + "\n", TitleFont);            
        //          tgl.setAlignment(Element.ALIGN_CENTER);
        //          doc.add(tgl);
        doc.add(Chunk.NEWLINE);

        PdfPTable table = new PdfPTable(header.length);
        table.setWidthPercentage(100f);

        for (String head : header) {
            table.addCell(new PdfPCell(new Phrase(head, normBold)));
        }

        for (String[] obj : data) {
            for (int i = 0; i < header.length; i++) {
                table.addCell(new PdfPCell(new Phrase(obj[i], norm)));
            }

        }

        //float[] columnWidths = new float[] {10f, 20f, 30f, 10f};
        table.setWidths(columnWidths);

        doc.add(table);

        //            Paragraph stamp = new Paragraph(new Chunk("this report has generated with QCMS by " + System.getProperty("user.name") + " on " + new Date(), litle));
        //            stamp.setAlignment(Element.ALIGN_BOTTOM);
        //            stamp.setAlignment(Element.ALIGN_CENTER);
        //            doc.add(stamp);
        //
        //            Paragraph tanda = new Paragraph(new Chunk("Mengetahui,", norm));
        //            tanda.setSpacingBefore(100);
        //            tanda.setAlignment(Element.ALIGN_RIGHT);
        //            tanda.setAlignment(Element.ALIGN_BOTTOM);
        //            doc.add(tanda);
        //
        //            Paragraph nama = new Paragraph(new Chunk("MANAGER Dept.RnQ", norm));
        //            nama.setSpacingBefore(30);
        //            nama.setAlignment(Element.ALIGN_RIGHT);
        //            nama.setAlignment(Element.ALIGN_BOTTOM);
        //            doc.add(nama);
        doc.close();
    } catch (DocumentException | FileNotFoundException ex) {
        Logger.getLogger(PDFconverter.class.getName()).log(Level.SEVERE, null, ex);
    }

}