Example usage for com.lowagie.text Paragraph setLeading

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

Introduction

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

Prototype

public void setLeading(float fixedLeading, float multipliedLeading) 

Source Link

Document

Sets the leading fixed and variable.

Usage

From source file:com.amphisoft.epub2pdf.content.TextFactory.java

License:Open Source License

public Paragraph newParagraph() {
    Paragraph p = new Paragraph();
    p.setAlignment(alignment.value);// w  w  w .  ja v a2  s .c  om
    p.setFont(_defaultFont);
    currentFont = _defaultFont;
    p.setHyphenation(new HyphenationAuto("en", "US", 2, 2));
    p.setLeading(0F, getCurrentLeadingMultiplier());
    p.setSpacingAfter(_defaultFont.getSize() * 0.33F);
    currentParagraph = p;
    return p;
}

From source file:com.amphisoft.epub2pdf.content.TextFactory.java

License:Open Source License

public Paragraph newParagraphPre() {
    Paragraph p = new Paragraph();
    p.setAlignment(ITAlignment.LEFT.value);
    p.setFont(_defaultFontMono);/*w  w w .jav a 2s.com*/
    currentFont = _defaultFontMono;
    p.setLeading(0F, getCurrentLeadingMultiplier());
    p.setSpacingAfter(_defaultFont.getSize() * 0.33F);
    currentParagraph = p;
    return p;
}

From source file:com.amphisoft.epub2pdf.content.TextFactory.java

License:Open Source License

public Paragraph newHeadline(int i) {
    if (i < 1) {
        i = 1;/*from w  w w .  j  a v  a 2  s  . c  o  m*/
    }
    if (i > 6) {
        i = 6;
    }
    Font hFont = FontFactory.getFont(_defaultFont.getFamilyname(), FontFactory.defaultEncoding,
            BaseFont.EMBEDDED, baseFontSize * HMULTS[i - 1], Font.BOLD);
    Paragraph h = new Paragraph();
    h.setAlignment(ITAlignment.CENTER.value);
    h.setFont(hFont);
    currentFont = hFont;
    h.setLeading(0F, getCurrentLeadingMultiplier());
    h.setSpacingAfter(_defaultFont.getSize() * 0.33F);
    currentParagraph = h;
    return h;
}

From source file:com.ideaspymes.proyecttemplate.stock.web.ProductoConsultaBean.java

public String createPdf() throws IOException, DocumentException {

    EtiquetaConf conf = etiquetaConfDAO.getEtiquetaConfDefault();

    if (hayParaImprimir() && conf != null) {

        HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance()
                .getExternalContext().getResponse();
        response.setContentType("application/x-pdf");
        response.setHeader("Content-Disposition", "attachment; filename=\"etiquetas.pdf\"");

        float ancho = Utilities.millimetersToPoints(conf.getAnchoHoja().floatValue());
        System.out.println("Ancho: " + ancho);
        float largo = Utilities.millimetersToPoints(conf.getLargoHoja().floatValue());
        System.out.println("Alto: " + largo);

        // step 1
        Document document = new Document(new Rectangle(ancho, largo));
        // step 2

        document.setMargins(0f, 0f, 0f, 0f);

        PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
        // step 3
        document.open();/*from   w w w. j a va2 s .c  o  m*/

        // step 4
        PdfContentByte cb = writer.getDirectContent();

        for (Producto p : getLista()) {
            if (p.getCantidadEtiquetas() > 0) {

                PdfPTable table = new PdfPTable(2);
                table.setWidthPercentage(96);

                Font fontbold = FontFactory.getFont("Times-Roman", 8, Font.NORMAL);

                Chunk productTitle = new Chunk("HC", fontbold);

                Paragraph pTitile = new Paragraph(productTitle);
                pTitile.setAlignment(Element.ALIGN_LEFT);
                pTitile.setLeading(6, 0);

                PdfPCell cellTitle = new PdfPCell();
                cellTitle.setHorizontalAlignment(Element.ALIGN_LEFT);
                cellTitle.setVerticalAlignment(Element.ALIGN_TOP);
                cellTitle.setBorder(Rectangle.NO_BORDER);
                cellTitle.addElement(pTitile);

                Font font2 = FontFactory.getFont("Times-Roman", conf.getTamDescripcion().floatValue(),
                        Font.NORMAL);

                Chunk productName = new Chunk(p.getNombre(), font2);

                Paragraph pName = new Paragraph(productName);
                pName.setAlignment(Element.ALIGN_CENTER);
                //pTitile.setLeading(0, 1);

                cellTitle.addElement(pName);

                table.addCell(cellTitle);

                Barcode39 code39 = new Barcode39();
                code39.setCode(p.getCodigo());
                //code39.setCodeType(Barcode.EAN13);
                code39.setBarHeight(conf.getAltoCodBarra().floatValue());
                //codeEan.setX(0.7f);
                code39.setSize(conf.getTamDescripcion().floatValue());
                //code39.setAltText("HC - " + p.getNombre());

                PdfPCell cellBarcode = new PdfPCell();
                cellBarcode.setHorizontalAlignment(Element.ALIGN_CENTER);
                cellBarcode.setBorder(Rectangle.NO_BORDER);
                cellBarcode.addElement(code39.createImageWithBarcode(cb, null, Color.BLACK));

                table.addCell(cellBarcode);

                for (int i = 0; i < p.getCantidadEtiquetas(); i++) {
                    document.add(table);
                    document.newPage();
                }
            }
        }

        // step 5
        document.close();

        response.getOutputStream().flush();
        response.getOutputStream().close();
        FacesContext.getCurrentInstance().responseComplete();
    } else {
        FacesContext.getCurrentInstance().addMessage(null,
                new FacesMessage(FacesMessage.SEVERITY_ERROR, "No hay nada que imprimir", ""));
    }
    return null;
}

From source file:com.jd.survey.web.pdf.StatisticsPdf.java

License:Open Source License

private void writeEntry(Document document, String label, String value) throws Exception {
    Paragraph questionParagraph = new Paragraph();
    questionParagraph.setLeading(14, 0);
    questionParagraph.setIndentationLeft(18);
    questionParagraph.add(new Chunk(label.trim() + ": ", boldedFont));
    questionParagraph.add(new Chunk(value == null ? "" : value.trim(), normalFont));
    document.add(questionParagraph);//from w  ww  . jav  a2s  . com
}

From source file:com.jd.survey.web.pdf.StatisticsPdf.java

License:Open Source License

private void writeEntry(Document document, String label) throws Exception {
    Paragraph questionParagraph = new Paragraph();
    questionParagraph.setLeading(14, 0);
    questionParagraph.setIndentationLeft(18);
    questionParagraph.add(new Chunk(label.trim(), boldedFont));
    document.add(questionParagraph);/*from   w  w w  .j  a  v a  2  s . c o  m*/
}

From source file:com.jd.survey.web.pdf.StatisticsPdf.java

License:Open Source License

private void writeEntry(Document document, String label, double value) throws Exception {
    Paragraph questionParagraph = new Paragraph();
    questionParagraph.setLeading(14, 0);
    questionParagraph.setIndentationLeft(18);
    questionParagraph.add(new Chunk(label.trim() + ": ", boldedFont));
    questionParagraph.add(new Chunk(
            BigDecimalValidator.getInstance().format(value, LocaleContextHolder.getLocale()), normalFont));
    document.add(questionParagraph);/*from   www  . j ava 2  s . co m*/
}

From source file:com.jd.survey.web.pdf.StatisticsPdf.java

License:Open Source License

private void writeEntry(Document document, String label, Date value, String dateFormat) throws Exception {
    Paragraph questionParagraph = new Paragraph();
    questionParagraph.setLeading(14, 0);
    questionParagraph.setIndentationLeft(18);
    questionParagraph.add(new Chunk(label.trim() + ": ", boldedFont));
    questionParagraph.add(new Chunk(DateValidator.getInstance().format(value, dateFormat), normalFont));
    document.add(questionParagraph);/*w  ww.  j  av a 2s  .c  o  m*/
}

From source file:com.jd.survey.web.pdf.StatisticsPdf.java

License:Open Source License

private void writeCurrencyEntry(Document document, String label, double value) throws Exception {
    Paragraph questionParagraph = new Paragraph();
    questionParagraph.setLeading(14, 0);
    questionParagraph.setIndentationLeft(18);
    questionParagraph.add(new Chunk(label.trim() + ": ", boldedFont));
    questionParagraph.add(new Chunk(
            CurrencyValidator.getInstance().format(value, LocaleContextHolder.getLocale()), normalFont));
    document.add(questionParagraph);/*from w w w  . j  a v a2s  .c  o m*/
}

From source file:com.jd.survey.web.pdf.SurveyPdf.java

License:Open Source License

private void writeAnswer(Document document, String questionText, boolean answerValue, String falseMessage,
        String trueMessage) throws Exception {

    //String falseString ="False";  
    //String trueString = "True";

    Paragraph questionParagraph = new Paragraph();
    questionParagraph.setLeading(14, 0);
    questionParagraph.add(new Chunk(questionText.trim() + ": ", boldedFont));
    questionParagraph.add(new Chunk(answerValue ? trueMessage : falseMessage, normalFont));
    document.add(questionParagraph);//from  w ww  .jav a2  s.c om
}