Example usage for com.itextpdf.text Paragraph setMultipliedLeading

List of usage examples for com.itextpdf.text Paragraph setMultipliedLeading

Introduction

In this page you can find the example usage for com.itextpdf.text Paragraph setMultipliedLeading.

Prototype

public void setMultipliedLeading(final float multipliedLeading) 

Source Link

Document

Sets the variable leading.

Usage

From source file:avalonscrollmaker20.AnothakScribe.java

License:Open Source License

public void writeToDoc(ArrayList<AnothakScroll> spellList, boolean simpleMode) {
    // Format content for inserting into a PDF
    for (int i = 0; i < spellList.size(); i++) {
        Paragraph spellCode = new Paragraph(spellList.get(i).spellCode, f_code);
        spellCode.setAlignment(ElementTags.ALIGN_RIGHT);
        spellCode.setMultipliedLeading(0.5f);
        spellCode.setIndentationRight(15f);

        Paragraph spellTitle = new Paragraph(spellList.get(i).spellTitle + "\n", f_title);
        spellTitle.setAlignment(ElementTags.ALIGN_CENTER);
        spellTitle.setMultipliedLeading(0.5f);
        spellTitle.setSpacingAfter(36f);

        Paragraph spellCircleSchool;//w w w.  j a va 2s.  c o  m
        if (spellList.get(i).isPure())
            spellCircleSchool = new Paragraph(spellList.get(i).spellCircle.toString() + " Circle\n    of "
                    + spellList.get(i).spellOldSchool.toString(), f_schoolPure);
        else // !spellList.get( i ).isPure()
            spellCircleSchool = new Paragraph(spellList.get(i).spellCircle.toString() + " Circle\n    of "
                    + spellList.get(i).spellOldSchool.toString(), f_school);
        spellCircleSchool.setAlignment(ElementTags.ALIGN_LEFT);
        spellCircleSchool.setIndentationLeft(18f);
        spellCircleSchool.setMultipliedLeading(1.75f);

        Paragraph sourceKeu = new Paragraph(spellList.get(i).sourceKeu.toString() + "|~", f_keu);
        sourceKeu.setAlignment(ElementTags.ALIGN_RIGHT);
        sourceKeu.setIndentationRight(36f);
        sourceKeu.setMultipliedLeading(1f);

        Paragraph directionKeu = new Paragraph("", f_keu);
        directionKeu.setAlignment(ElementTags.ALIGN_RIGHT);
        directionKeu.setIndentationRight(90f);
        directionKeu.setMultipliedLeading(0.875f);

        Paragraph destinationKeu = new Paragraph(spellList.get(i).destinationKeu.toString() + "|~", f_keu);
        destinationKeu.setAlignment(ElementTags.ALIGN_RIGHT);
        destinationKeu.setIndentationRight(36f);
        destinationKeu.setMultipliedLeading(0.625f);

        Paragraph phraseCommon;
        Paragraph phraseSymbol;

        if (spellList.get(i).spellCircle != Circle.SEVENTH
                && spellList.get(i).spellCircle != Circle.PURE_SEVENTH) {
            phraseCommon = new Paragraph("", f_phraseCommon);
            phraseCommon.setSpacingAfter(27f);
            phraseSymbol = new Paragraph("", f_phraseSymbol);
            if ((i % 2) <= 0)
                phraseSymbol.setSpacingAfter(90f);
            else // ( (i % 2) > 0 )
                phraseSymbol.setSpacingAfter(0f);
        } else {
            phraseCommon = new Paragraph("", f_phraseCommonBreath);
            phraseCommon.setSpacingAfter(36f);
            phraseSymbol = new Paragraph("", f_phraseSymbolBreath);
            if ((i % 2) <= 0)
                phraseSymbol.setSpacingAfter(103.5f);
            else // ( (i % 2) > 0 )
                phraseSymbol.setSpacingAfter(0f);
        }

        phraseCommon.setAlignment(ElementTags.ALIGN_CENTER);
        phraseCommon.setMultipliedLeading(1.5f);
        for (AnothakScroll.Word w : spellList.get(i).liersethPhrase_Common)
            phraseCommon.add(w.toString() + " ");

        if (simpleMode) {
            phraseSymbol.setAlignment(ElementTags.ALIGN_CENTER);
            phraseSymbol.setSpacingBefore(36f);
            phraseSymbol.setSpacingAfter(0f);
            phraseSymbol.setMultipliedLeading(0.75f);
        } else // not simpleMode
        {
            phraseSymbol.setAlignment(ElementTags.ALIGN_CENTER);
            phraseSymbol.setMultipliedLeading(0.5f);
        }

        for (AnothakScroll.Symbol s : spellList.get(i).liersethPhrase_Symbol) {
            phraseSymbol.add(s.toString());
        }

        // Add content to the document
        try {
            if (simpleMode)
                doc_scrolls.add(phraseSymbol);
            else {
                Image tmpImage = null;
                tmpImage = spellList.get(i).backgroundImageFull;

                if (tmpImage != null) {
                    if ((i % 2) <= 0)
                        tmpImage.setAbsolutePosition(9f, 405f);
                    else // (i % 2) >= 0
                        tmpImage.setAbsolutePosition(9f, 9f);

                    doc_scrolls.add(tmpImage);
                }

                //doc_scrolls.add( Chunk.NEWLINE );
                doc_scrolls.add(spellCode);
                doc_scrolls.add(spellTitle);

                // Crap, I hate formatting
                MultiColumnText mct = new MultiColumnText(108f);
                mct.addRegularColumns(doc_scrolls.left(), doc_scrolls.right(), 54f, 2);
                mct.addElement(spellCircleSchool);
                mct.addElement(sourceKeu);
                mct.addElement(directionKeu);
                mct.addElement(destinationKeu);

                doc_scrolls.add(mct);

                doc_scrolls.add(new Chunk("\n", new Font(Font.FontFamily.COURIER, 18f, Font.NORMAL)));

                doc_scrolls.add(phraseCommon);
                doc_scrolls.add(phraseSymbol);

                if ((i % 2) > 0)
                    doc_scrolls.newPage();
            }

        } catch (Exception ex) {
            System.err.println(ex + "\nProgram closing.");
            System.exit(4);
        }
    }

    // Close the Document
    doc_scrolls.close();

    JOptionPane.showMessageDialog(null, doc_name + " was printed successfully!", "Print Status",
            JOptionPane.INFORMATION_MESSAGE);
}

From source file:be.kcbj.placemat.Placemat.java

License:Open Source License

private PdfPCell generateCell(Sponsor sponsor, float cellHeight) throws IOException, BadElementException {
    int numLines = 0;
    Paragraph p = new Paragraph();

    if (sponsor.image != null) {
        Image image = Image.getInstance(SponsorManager.getImageUrl(sponsor.image));
        if (sponsor.imageWidth != 0) {
            image.scaleToFit(sponsor.imageWidth, 1000);
        } else if (sponsor.imageHeight != 0) {
            image.scaleToFit(1000, sponsor.imageHeight);
        }//from ww w . j  a va 2 s  .c  o m
        Chunk imageChunk = new Chunk(image, 0, 0, true);
        p.add(imageChunk);
    }

    if (sponsor.twoColumns) {
        StringBuilder sb = new StringBuilder();
        if (sponsor.name != null) {
            sb.append(sponsor.name);
        }
        if (sponsor.name2 != null) {
            if (sb.length() > 0) {
                sb.append(" - ");
            }
            sb.append(sponsor.name2);
        }
        if (sponsor.address != null) {
            if (sb.length() > 0) {
                sb.append(" - ");
            }
            sb.append(sponsor.address);
        }
        if (sponsor.address2 != null) {
            if (sb.length() > 0) {
                sb.append(" - ");
            }
            sb.append(sponsor.address2);
        }
        p.add(Chunk.NEWLINE);
        p.add(new Chunk(sb.toString(), new Font(Font.FontFamily.HELVETICA, 8, Font.NORMAL)));
        numLines++;
    } else {
        if (sponsor.twoRows && sponsor.image != null) {
            p.add(Chunk.NEWLINE);
        }
        if (sponsor.name != null) {
            p.add(generateFittedChunk(sponsor.name, Font.BOLD));
            numLines++;
        }
        if (sponsor.name2 != null) {
            p.add(Chunk.NEWLINE);
            p.add(generateFittedChunk(sponsor.name2, Font.BOLD));
            numLines++;
        }
        if (sponsor.address != null) {
            p.add(new Chunk("\n\n", new Font(Font.FontFamily.HELVETICA, 2, Font.NORMAL)));
            p.add(new Chunk(sponsor.address, new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
            numLines++;
        }
        if (sponsor.address2 != null) {
            p.add(Chunk.NEWLINE);
            p.add(new Chunk(sponsor.address2, new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
            numLines++;
        }
    }
    p.setPaddingTop(0);
    p.setSpacingBefore(0);
    p.setAlignment(Element.ALIGN_CENTER);
    p.setMultipliedLeading(numLines <= 3 ? 1.3f : 1.1f);

    PdfPCell cell = new PdfPCell();
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setFixedHeight(cellHeight);
    if (sponsor.twoColumns) {
        cell.setColspan(2);
    }
    if (sponsor.twoRows) {
        cell.setRowspan(2);
        if (sponsor.image == null) {
            p.setMultipliedLeading(p.getMultipliedLeading() * 1.5f);
        }
    }
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setCellEvent(CELL_EVENT);
    cell.setPaddingBottom(4);
    cell.addElement(p);
    if (sponsor.isTodo()) {
        cell.setBackgroundColor(BaseColor.ORANGE);
    }

    return cell;
}

From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java

License:Apache License

/**
 * Default  ?//  w ww.ja v a 2  s .  c o  m
 *
 * @param text  text
 * @return Paragraph
 */
public static Paragraph getDefault(String text) {
    Paragraph ph = new Paragraph(text, fnNormal);
    ph.setMultipliedLeading(1.8F);
    ph.setIndentationLeft(23);
    ph.setSpacingAfter(14);
    return ph;
}

From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java

License:Apache License

/**
 * Default  ?(Bold)//from  w w  w. ja v  a  2s.  c  o m
 *
 * @param text  text
 * @return Paragraph
 */
public static Paragraph getDefaultPoint(String text) {
    Font font = new Font(bfKorean, 10, Font.BOLD);

    Paragraph ph = new Paragraph(" " + text, font);
    ph.setMultipliedLeading(1.8F);
    ph.setIndentationLeft(45);
    ph.setSpacingAfter(14);
    return ph;
}

From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java

License:Apache License

/**
 * Default  ?(RED)/*from  w ww.  j a  v a 2s .c o  m*/
 *
 * @param text  text
 * @param style Font style
 * @return Paragraph
 */
public static Paragraph getDefaultRed(String text, int style) {
    Font font = new Font(bfKorean, 10, style);
    font.setColor(new BaseColor(255, 0, 0));

    Paragraph ph = new Paragraph(text, font);
    ph.setMultipliedLeading(1.8F);
    ph.setIndentationLeft(45);
    ph.setSpacingAfter(14);
    return ph;
}