Example usage for com.lowagie.text Paragraph setSpacingBefore

List of usage examples for com.lowagie.text Paragraph setSpacingBefore

Introduction

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

Prototype

public void setSpacingBefore(float spacing) 

Source Link

Document

Sets the spacing before this paragraph.

Usage

From source file:pl.exsio.ca.app.report.terraincard.view.TerrainCardsView.java

License:Open Source License

private Cell getColumnDescCell(String desc) throws Exception {
    Paragraph p = new Paragraph(t(desc), this.getFont());
    p.getFont().setSize(8);/*from  w w  w .ja v a 2s.c o m*/
    p.getFont().setStyle(Font.BOLDITALIC);
    p.setSpacingAfter(2);
    p.setSpacingBefore(2);
    Cell cell = new Cell(p);
    cell.setBackgroundColor(new Color(230, 230, 230));
    return cell;
}

From source file:tufts.vue.PresentationNotes.java

License:Educational Community License

public static void createSpeakerNotes1PerPage(File file) {

    // step 1: creation of a document-object

    //This is a bit of a mess but because of hte bugs with drawing the slides
    //the easy way, we have no other choice but to render them directly onto the pdf
    //which makes it hard to use tables for stuff like formatting text...so we'll render
    // a blank table cell then render the image into it.
    Document document = new Document();

    try {/*from   w w  w . j a  v  a 2  s  .com*/
        GUI.activateWaitCursor();
        // step 2:
        // we create a writer that listens to the document
        // and directs a PDF-stream to a file            
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));

        // step 3: we open the document
        document.open();

        PdfPTable table;
        PdfPCell cell;
        int currentIndex = VUE.getActivePathway().getIndex();

        VUE.getActivePathway().setIndex(-1);

        for (LWPathway.Entry entry : VUE.getActivePathway().getEntries()) {

            final LWSlide slide = entry.produceSlide();
            final LWComponent toDraw = (slide == null ? entry.node : slide);
            final String notes = entry.getNotes();
            //String label = entry.getLabel();

            PdfContentByte cb = writer.getDirectContent();

            Point2D.Float offset = new Point2D.Float();

            Rectangle2D bounds = null;

            //if (!entry.isMapView())
            bounds = slide.getBounds();
            //else 
            //bounds = entry.getFocal().getBounds();

            Dimension page = null;

            page = new Dimension(432, 324);

            PdfTemplate tp = cb.createTemplate(432, 324);
            double scale = ZoomTool.computeZoomFit(page, 5, bounds, offset, true);
            PdfGraphics2D g2d = (PdfGraphics2D) tp.createGraphics(432, 324, getFontMapper(), false, 60.0f);
            DrawContext dc = new DrawContext(g2d, scale, -offset.x, -offset.y, null, // frame would be the PageFormat offset & size rectangle
                    entry.isMapView() ? entry.getFocal() : slide, false); // todo: absolute links shouldn't be spec'd here

            dc.setClipOptimized(false);
            dc.setPrintQuality();
            /*if (!entry.isMapView())                   
               slide.drawZero(dc);
            else
            {                
               entry.getFocal().draw(dc);
            }*/
            toDraw.drawFit(dc, 0);

            g2d.dispose();

            cb.addTemplate(tp, 80, 482);

            //Paragraph p = new Paragraph();
            //p.setExtraParagraphSpace(330);
            // p.setSpacingBefore(330f);
            //  p.setAlignment(Element.ALIGN_CENTER);

            Paragraph phrase = new Paragraph(notes);
            //phrase.setExtraParagraphSpace(340f);
            phrase.setSpacingBefore(320f);
            phrase.setKeepTogether(true);
            //cell = new PdfPCell(phrase);
            //cell.setBorder(0);
            //         table = new PdfPTable(new float[]{ 1 });
            //        table.setWidthPercentage(100.0f);
            //        table.getDefaultCell().setBorder(0);
            //table.getDefaultCell().setPaddingTop(30);

            //PdfPCell c2 = new PdfPCell();
            //c2.setFixedHeight(340); //slides are 540x405
            //c2.setBorder(0);
            //table.addCell(c2);                
            //table.addCell(cell);
            //table.setKeepTogether(false);
            //cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);

            //p.add(table);
            //System.out.println("CELL HEIGHT : " + cell.getHeight());
            //Section s1 = new Section();
            //ColumnText chunk2 = new ColumnText(cb);
            //chunk2.setText(phrase);
            //chunk2.setSi
            //chunk2.setSimpleColumn(phrase,70, 330, document.getPageSize().width()-70,document.getPageSize().height()-70,15, Element.ALIGN_LEFT);
            // chunk2.go();
            //PdfChunk chunk2 = new PdfChunk);
            Paragraph p2 = new Paragraph(" ");
            p2.setKeepTogether(false);
            phrase.setKeepTogether(false);
            // p2.setExtraParagraphSpace(230f);
            document.add(p2);
            document.add(phrase);
            document.newPage();
        }

        VUE.getActivePathway().setIndex(currentIndex);
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    } finally {
        GUI.clearWaitCursor();
    }

    // step 5: we close the document
    document.close();
}

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);
    documento.add(paragrafo);/*from   ww w  .ja v a  2  s.  c  o  m*/
    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);

        }
    }

}