Search in sources :

Example 1 with LineSeparator

use of com.lowagie.text.pdf.draw.LineSeparator in project qcadoo by qcadoo.

the class PdfHelperImpl method addDocumentHeader.

@Override
public void addDocumentHeader(final Document document, final String name, final String documenTitle, final String documentAuthor, final Date date) throws DocumentException {
    SimpleDateFormat df = new SimpleDateFormat(DateUtils.L_DATE_TIME_FORMAT, getLocale());
    LineSeparator line = new LineSeparator(2, 100f, ColorUtils.getLineDarkColor(), Element.ALIGN_LEFT, 0);
    document.add(Chunk.NEWLINE);
    Paragraph title = new Paragraph(new Phrase(documenTitle, FontUtils.getDejavuBold17Light()));
    title.add(new Phrase(" " + name, FontUtils.getDejavuBold17Dark()));
    title.setSpacingAfter(7f);
    document.add(title);
    document.add(line);
    PdfPTable userAndDate = new PdfPTable(2);
    userAndDate.setWidthPercentage(100f);
    userAndDate.setHorizontalAlignment(Element.ALIGN_LEFT);
    userAndDate.getDefaultCell().setBorderWidth(0);
    Paragraph userParagraph = new Paragraph(new Phrase(documentAuthor, FontUtils.getDejavuRegular9Light()));
    userParagraph.add(new Phrase(" " + getDocumentAuthor(), FontUtils.getDejavuRegular9Dark()));
    Paragraph dateParagraph = new Paragraph(df.format(date), FontUtils.getDejavuRegular9Light());
    userAndDate.addCell(userParagraph);
    userAndDate.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
    userAndDate.addCell(dateParagraph);
    userAndDate.setSpacingAfter(14f);
    document.add(userAndDate);
}
Also used : PdfPTable(com.lowagie.text.pdf.PdfPTable) Phrase(com.lowagie.text.Phrase) SimpleDateFormat(java.text.SimpleDateFormat) LineSeparator(com.lowagie.text.pdf.draw.LineSeparator) Paragraph(com.lowagie.text.Paragraph)

Example 2 with LineSeparator

use of com.lowagie.text.pdf.draw.LineSeparator in project OpenPDF by LibrePDF.

the class SAXiTextHandler method handleStartingTags.

/**
 * This method deals with the starting tags.
 *
 * @param name       the name of the tag
 * @param attributes the list of attributes
 */
public void handleStartingTags(String name, Properties attributes) {
    if (ignore || ElementTags.IGNORE.equals(name)) {
        ignore = true;
        return;
    }
    // maybe there is some meaningful data that wasn't between tags
    if (currentChunk != null && isNotBlank(currentChunk.getContent())) {
        TextElementArray current;
        try {
            current = (TextElementArray) stack.pop();
        } catch (EmptyStackException ese) {
            if (bf == null) {
                current = new Paragraph("", new Font());
            } else {
                current = new Paragraph("", new Font(this.bf));
            }
        }
        current.add(currentChunk);
        stack.push(current);
        currentChunk = null;
    }
    // chunks
    if (ElementTags.CHUNK.equals(name)) {
        currentChunk = ElementFactory.getChunk(attributes);
        if (bf != null) {
            currentChunk.setFont(new Font(this.bf));
        }
        return;
    }
    // symbols
    if (ElementTags.ENTITY.equals(name)) {
        Font f = new Font();
        if (currentChunk != null) {
            handleEndingTags(ElementTags.CHUNK);
            f = currentChunk.getFont();
        }
        currentChunk = EntitiesToSymbol.get(attributes.getProperty(ElementTags.ID), f);
        return;
    }
    // phrases
    if (ElementTags.PHRASE.equals(name)) {
        stack.push(ElementFactory.getPhrase(attributes));
        return;
    }
    // anchors
    if (ElementTags.ANCHOR.equals(name)) {
        stack.push(ElementFactory.getAnchor(attributes));
        return;
    }
    // paragraphs and titles
    if (ElementTags.PARAGRAPH.equals(name) || ElementTags.TITLE.equals(name)) {
        stack.push(ElementFactory.getParagraph(attributes));
        return;
    }
    // lists
    if (ElementTags.LIST.equals(name)) {
        stack.push(ElementFactory.getList(attributes));
        return;
    }
    // listitems
    if (ElementTags.LISTITEM.equals(name)) {
        stack.push(ElementFactory.getListItem(attributes));
        return;
    }
    // cells
    if (ElementTags.CELL.equals(name)) {
        stack.push(ElementFactory.getCell(attributes));
        return;
    }
    // tables
    if (ElementTags.TABLE.equals(name)) {
        Table table = ElementFactory.getTable(attributes);
        float[] widths = table.getProportionalWidths();
        for (int i = 0; i < widths.length; i++) {
            if (widths[i] == 0) {
                widths[i] = 100.0f / widths.length;
            }
        }
        try {
            table.setWidths(widths);
        } catch (BadElementException bee) {
            // this shouldn't happen
            throw new ExceptionConverter(bee);
        }
        stack.push(table);
        return;
    }
    // sections
    if (ElementTags.SECTION.equals(name)) {
        Element previous = stack.pop();
        Section section;
        try {
            section = ElementFactory.getSection((Section) previous, attributes);
        } catch (ClassCastException cce) {
            throw new ExceptionConverter(cce);
        }
        stack.push(previous);
        stack.push(section);
        return;
    }
    // chapters
    if (ElementTags.CHAPTER.equals(name)) {
        stack.push(ElementFactory.getChapter(attributes));
        return;
    }
    // images
    if (ElementTags.IMAGE.equals(name)) {
        try {
            Image img = ElementFactory.getImage(attributes);
            try {
                addImage(img);
                return;
            } catch (EmptyStackException ese) {
                // to the document
                try {
                    document.add(img);
                } catch (DocumentException de) {
                    throw new ExceptionConverter(de);
                }
                return;
            }
        } catch (Exception e) {
            throw new ExceptionConverter(e);
        }
    }
    // annotations
    if (ElementTags.ANNOTATION.equals(name)) {
        Annotation annotation = ElementFactory.getAnnotation(attributes);
        TextElementArray current;
        try {
            try {
                current = (TextElementArray) stack.pop();
                try {
                    current.add(annotation);
                } catch (Exception e) {
                    document.add(annotation);
                }
                stack.push(current);
            } catch (EmptyStackException ese) {
                document.add(annotation);
            }
            return;
        } catch (DocumentException de) {
            throw new ExceptionConverter(de);
        }
    }
    // newlines
    if (isNewline(name)) {
        TextElementArray current;
        try {
            current = (TextElementArray) stack.pop();
            current.add(Chunk.NEWLINE);
            stack.push(current);
        } catch (EmptyStackException ese) {
            if (currentChunk == null) {
                try {
                    document.add(Chunk.NEWLINE);
                } catch (DocumentException de) {
                    throw new ExceptionConverter(de);
                }
            } else {
                currentChunk.append("\n");
            }
        }
        return;
    }
    // newpage
    if (isNewpage(name)) {
        TextElementArray current;
        try {
            current = (TextElementArray) stack.pop();
            Chunk newPage = new Chunk("");
            newPage.setNewPage();
            if (bf != null) {
                newPage.setFont(new Font(this.bf));
            }
            current.add(newPage);
            stack.push(current);
        } catch (EmptyStackException ese) {
            document.newPage();
        }
        return;
    }
    if (ElementTags.HORIZONTALRULE.equals(name)) {
        TextElementArray current;
        LineSeparator hr = new LineSeparator(1.0f, 100.0f, null, Element.ALIGN_CENTER, 0);
        try {
            current = (TextElementArray) stack.pop();
            current.add(hr);
            stack.push(current);
        } catch (EmptyStackException ese) {
            try {
                document.add(hr);
            } catch (DocumentException de) {
                throw new ExceptionConverter(de);
            }
        }
        return;
    }
    // documentroot
    if (isDocumentRoot(name)) {
        String key;
        String value;
        // pagesize and orientation specific code suggested by Samuel Gabriel
        // Updated by Ricardo Coutinho. Only use if set in html!
        Rectangle pageSize = null;
        String orientation = null;
        for (Object o : attributes.keySet()) {
            key = (String) o;
            value = attributes.getProperty(key);
            try {
                // margin specific code suggested by Reza Nasiri
                if (ElementTags.LEFT.equalsIgnoreCase(key))
                    leftMargin = Float.parseFloat(value + "f");
                if (ElementTags.RIGHT.equalsIgnoreCase(key))
                    rightMargin = Float.parseFloat(value + "f");
                if (ElementTags.TOP.equalsIgnoreCase(key))
                    topMargin = Float.parseFloat(value + "f");
                if (ElementTags.BOTTOM.equalsIgnoreCase(key))
                    bottomMargin = Float.parseFloat(value + "f");
            } catch (Exception ex) {
                throw new ExceptionConverter(ex);
            }
            if (ElementTags.PAGE_SIZE.equals(key)) {
                try {
                    Field pageSizeField = PageSize.class.getField(value);
                    pageSize = (Rectangle) pageSizeField.get(null);
                } catch (Exception ex) {
                    throw new ExceptionConverter(ex);
                }
            } else if (ElementTags.ORIENTATION.equals(key)) {
                try {
                    if ("landscape".equals(value)) {
                        orientation = "landscape";
                    }
                } catch (Exception ex) {
                    throw new ExceptionConverter(ex);
                }
            } else {
                try {
                    document.add(new Meta(key, value));
                } catch (DocumentException de) {
                    throw new ExceptionConverter(de);
                }
            }
        }
        if (pageSize != null) {
            if ("landscape".equals(orientation)) {
                pageSize = pageSize.rotate();
            }
            document.setPageSize(pageSize);
        }
        document.setMargins(leftMargin, rightMargin, topMargin, bottomMargin);
        if (controlOpenClose)
            document.open();
    }
}
Also used : Meta(com.lowagie.text.Meta) Table(com.lowagie.text.Table) BadElementException(com.lowagie.text.BadElementException) Element(com.lowagie.text.Element) Rectangle(com.lowagie.text.Rectangle) Image(com.lowagie.text.Image) Chunk(com.lowagie.text.Chunk) Section(com.lowagie.text.Section) LineSeparator(com.lowagie.text.pdf.draw.LineSeparator) BaseFont(com.lowagie.text.pdf.BaseFont) Font(com.lowagie.text.Font) BadElementException(com.lowagie.text.BadElementException) EmptyStackException(java.util.EmptyStackException) DocumentException(com.lowagie.text.DocumentException) Annotation(com.lowagie.text.Annotation) Paragraph(com.lowagie.text.Paragraph) EmptyStackException(java.util.EmptyStackException) ExceptionConverter(com.lowagie.text.ExceptionConverter) Field(java.lang.reflect.Field) TextElementArray(com.lowagie.text.TextElementArray) DocumentException(com.lowagie.text.DocumentException)

Example 3 with LineSeparator

use of com.lowagie.text.pdf.draw.LineSeparator in project OpenPDF by LibrePDF.

the class HTMLWorker method startElement.

public void startElement(String tag, Map<String, String> style) {
    if (!tagsSupported.containsKey(tag)) {
        return;
    }
    try {
        this.style.applyStyle(tag, style);
        String follow = FactoryProperties.followTags.get(tag);
        if (follow != null) {
            Map<String, String> prop = new HashMap<>();
            prop.put(follow, null);
            cprops.addToChain(follow, prop);
            return;
        }
        FactoryProperties.insertStyle(style, cprops);
        if (tag.equals(HtmlTags.ANCHOR)) {
            cprops.addToChain(tag, style);
            if (currentParagraph == null) {
                currentParagraph = new Paragraph();
            }
            stack.push(currentParagraph);
            currentParagraph = new Paragraph();
            return;
        }
        if (tag.equals(HtmlTags.NEWLINE)) {
            if (currentParagraph == null) {
                currentParagraph = new Paragraph();
            }
            Chunk chunk = factoryProperties.createChunk("\n", cprops);
            currentParagraph.add(chunk);
            return;
        }
        if (tag.equals(HtmlTags.HORIZONTALRULE)) {
            // Attempting to duplicate the behavior seen on Firefox with
            // http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_hr_test
            // where an initial break is only inserted when the preceding element doesn't
            // end with a break, but a trailing break is always inserted.
            boolean addLeadingBreak = true;
            if (currentParagraph == null) {
                currentParagraph = new Paragraph();
                addLeadingBreak = false;
            }
            if (addLeadingBreak) {
                // Not a new paragraph
                int numChunks = currentParagraph.getChunks().size();
                if (numChunks == 0 || ((Chunk) (currentParagraph.getChunks().get(numChunks - 1))).getContent().endsWith("\n"))
                    addLeadingBreak = false;
            }
            String align = style.get("align");
            int hrAlign = Element.ALIGN_CENTER;
            if (align != null) {
                if (align.equalsIgnoreCase("left")) {
                    hrAlign = Element.ALIGN_LEFT;
                }
                if (align.equalsIgnoreCase("right")) {
                    hrAlign = Element.ALIGN_RIGHT;
                }
            }
            String width = style.get("width");
            float hrWidth = 1;
            if (width != null) {
                float tmpWidth = parseLength(width, Markup.DEFAULT_FONT_SIZE);
                if (tmpWidth > 0)
                    hrWidth = tmpWidth;
                if (!width.endsWith("%"))
                    // Treat a pixel width as 100% for now.
                    hrWidth = 100;
            }
            String size = style.get("size");
            float hrSize = 1;
            if (size != null) {
                float tmpSize = parseLength(size, Markup.DEFAULT_FONT_SIZE);
                if (tmpSize > 0) {
                    hrSize = tmpSize;
                }
            }
            if (addLeadingBreak) {
                currentParagraph.add(Chunk.NEWLINE);
            }
            currentParagraph.add(new LineSeparator(hrSize, hrWidth, null, hrAlign, currentParagraph.getLeading() / 2));
            currentParagraph.add(Chunk.NEWLINE);
            return;
        }
        if (tag.equals(HtmlTags.CHUNK) || tag.equals(HtmlTags.SPAN)) {
            cprops.addToChain(tag, style);
            return;
        }
        if (tag.equals(HtmlTags.IMAGE)) {
            String src = style.get(ElementTags.SRC);
            if (src == null) {
                return;
            }
            cprops.addToChain(tag, style);
            Image img = null;
            if (interfaceProps != null) {
                ImageProvider ip = (ImageProvider) interfaceProps.get("img_provider");
                if (ip != null) {
                    img = ip.getImage(src, (HashMap) style, cprops, document);
                }
                if (img == null) {
                    Map images = (HashMap) interfaceProps.get("img_static");
                    if (images != null) {
                        Image tim = (Image) images.get(src);
                        if (tim != null) {
                            img = Image.getInstance(tim);
                        }
                    } else {
                        if (!src.startsWith("http")) {
                            // relative src references only
                            String baseUrl = (String) interfaceProps.get("img_baseurl");
                            if (baseUrl != null) {
                                src = baseUrl + src;
                                img = Image.getInstance(src);
                            }
                        }
                    }
                }
            }
            if (img == null) {
                if (!src.startsWith("http")) {
                    String path = cprops.getOrDefault("image_path", "");
                    src = new File(path, src).getPath();
                }
                img = Image.getInstance(src);
            }
            String align = style.get("align");
            String width = style.get("width");
            String height = style.get("height");
            cprops.findProperty("before").flatMap(NumberUtilities::parseFloat).ifPresent(img::setSpacingBefore);
            cprops.findProperty("after").flatMap(NumberUtilities::parseFloat).ifPresent(img::setSpacingAfter);
            float actualFontSize = parseLength(cprops.getProperty(ElementTags.SIZE), Markup.DEFAULT_FONT_SIZE);
            if (actualFontSize <= 0f)
                actualFontSize = Markup.DEFAULT_FONT_SIZE;
            float widthInPoints = parseLength(width, actualFontSize);
            float heightInPoints = parseLength(height, actualFontSize);
            if (widthInPoints > 0 && heightInPoints > 0) {
                img.scaleAbsolute(widthInPoints, heightInPoints);
            } else if (widthInPoints > 0) {
                heightInPoints = img.getHeight() * widthInPoints / img.getWidth();
                img.scaleAbsolute(widthInPoints, heightInPoints);
            } else if (heightInPoints > 0) {
                widthInPoints = img.getWidth() * heightInPoints / img.getHeight();
                img.scaleAbsolute(widthInPoints, heightInPoints);
            }
            img.setWidthPercentage(0);
            if (align != null) {
                endElement("p");
                int ralign = Image.MIDDLE;
                if (align.equalsIgnoreCase("left"))
                    ralign = Image.LEFT;
                else if (align.equalsIgnoreCase("right"))
                    ralign = Image.RIGHT;
                img.setAlignment(ralign);
                Img i = null;
                boolean skip = false;
                if (interfaceProps != null) {
                    i = (Img) interfaceProps.get("img_interface");
                    if (i != null)
                        skip = i.process(img, (HashMap) style, cprops, document);
                }
                if (!skip)
                    document.add(img);
                cprops.removeChain(tag);
            } else {
                cprops.removeChain(tag);
                if (currentParagraph == null) {
                    currentParagraph = FactoryProperties.createParagraph(cprops);
                }
                currentParagraph.add(new Chunk(img, 0, 0));
            }
            return;
        }
        endElement("p");
        if (tag.equals("h1") || tag.equals("h2") || tag.equals("h3") || tag.equals("h4") || tag.equals("h5") || tag.equals("h6")) {
            if (!style.containsKey(ElementTags.SIZE)) {
                int v = 7 - Integer.parseInt(tag.substring(1));
                style.put(ElementTags.SIZE, Integer.toString(v));
            }
            cprops.addToChain(tag, style);
            return;
        }
        if (tag.equals(HtmlTags.UNORDEREDLIST)) {
            if (pendingLI)
                endElement(HtmlTags.LISTITEM);
            skipText = true;
            cprops.addToChain(tag, style);
            com.lowagie.text.List list = new com.lowagie.text.List(false);
            try {
                list.setIndentationLeft(Float.parseFloat(cprops.getProperty("indent")));
            } catch (Exception e) {
                list.setAutoindent(true);
            }
            list.setListSymbol("\u2022");
            stack.push(list);
            return;
        }
        if (tag.equals(HtmlTags.ORDEREDLIST)) {
            if (pendingLI)
                endElement(HtmlTags.LISTITEM);
            skipText = true;
            cprops.addToChain(tag, style);
            com.lowagie.text.List list = new com.lowagie.text.List(true);
            try {
                list.setIndentationLeft(Float.parseFloat(cprops.getProperty("indent")));
            } catch (Exception e) {
                list.setAutoindent(true);
            }
            stack.push(list);
            return;
        }
        if (tag.equals(HtmlTags.LISTITEM)) {
            if (pendingLI)
                endElement(HtmlTags.LISTITEM);
            skipText = false;
            pendingLI = true;
            cprops.addToChain(tag, style);
            ListItem item = FactoryProperties.createListItem(cprops);
            stack.push(item);
            return;
        }
        if (tag.equals(HtmlTags.DIV) || tag.equals(HtmlTags.BODY) || tag.equals("p")) {
            cprops.addToChain(tag, style);
            return;
        }
        if (tag.equals(HtmlTags.PRE)) {
            if (!style.containsKey(ElementTags.FACE)) {
                style.put(ElementTags.FACE, "Courier");
            }
            cprops.addToChain(tag, style);
            isPRE = true;
            return;
        }
        if (tag.equals("tr")) {
            if (pendingTR)
                endElement("tr");
            skipText = true;
            pendingTR = true;
            cprops.addToChain("tr", style);
            return;
        }
        if (tag.equals("td") || tag.equals("th")) {
            if (pendingTD)
                endElement(tag);
            skipText = false;
            pendingTD = true;
            cprops.addToChain("td", style);
            stack.push(new IncCell(tag, cprops));
            return;
        }
        if (tag.equals("table")) {
            cprops.addToChain("table", style);
            IncTable table = new IncTable(style);
            stack.push(table);
            tableState.push(new boolean[] { pendingTR, pendingTD });
            pendingTR = pendingTD = false;
            skipText = true;
            return;
        }
    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
Also used : HashMap(java.util.HashMap) Image(com.lowagie.text.Image) LineSeparator(com.lowagie.text.pdf.draw.LineSeparator) ArrayList(java.util.ArrayList) List(java.util.List) Chunk(com.lowagie.text.Chunk) IOException(java.io.IOException) DocumentException(com.lowagie.text.DocumentException) Paragraph(com.lowagie.text.Paragraph) ExceptionConverter(com.lowagie.text.ExceptionConverter) ListItem(com.lowagie.text.ListItem) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File)

Example 4 with LineSeparator

use of com.lowagie.text.pdf.draw.LineSeparator in project OpenPDF by LibrePDF.

the class ColumnTextSeparator method test_columnTextSeparator.

@Test
public void test_columnTextSeparator() throws Exception {
    filePath = System.getProperty("user.dir") + "/src/test/resources";
    File RESULT = new File(filePath + "/columnTextSeparator.pdf");
    // step 1
    Document document = new Document(PageSize.A4);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter pdfWriter = PdfWriter.getInstance(document, baos);
    document.open();
    PdfContentByte wrote = pdfWriter.getDirectContent();
    ColumnText ct = new ColumnText(wrote);
    Phrase p = null;
    for (int i = 0; i < 3; i++) {
        p = new Phrase();
        p.add(new LineSeparator(0.3f, 100, null, Element.ALIGN_CENTER, -2));
        p.add("test");
        ct.addText(p);
        ct.addText(Chunk.NEWLINE);
    }
    ct.setAlignment(Element.ALIGN_JUSTIFIED);
    ct.setExtraParagraphSpace(6);
    ct.setLeading(0, 1.2f);
    ct.setFollowingIndent(27);
    int linesWritten = 0;
    int column = 0;
    int status = ColumnText.START_COLUMN;
    while (ColumnText.hasMoreText(status)) {
        ct.setSimpleColumn(COLUMNS[column][0], COLUMNS[column][1], COLUMNS[column][2], COLUMNS[column][3]);
        ct.setYLine(COLUMNS[column][3]);
        status = ct.go();
        linesWritten += ct.getLinesWritten();
        column = Math.abs(column - 1);
        if (column == 0)
            document.newPage();
    }
    document.close();
    FileOutputStream fos = new FileOutputStream(RESULT);
    fos.write(baos.toByteArray());
    fos.close();
}
Also used : ColumnText(com.lowagie.text.pdf.ColumnText) PdfWriter(com.lowagie.text.pdf.PdfWriter) FileOutputStream(java.io.FileOutputStream) PdfContentByte(com.lowagie.text.pdf.PdfContentByte) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Phrase(com.lowagie.text.Phrase) Document(com.lowagie.text.Document) File(java.io.File) LineSeparator(com.lowagie.text.pdf.draw.LineSeparator) Test(org.junit.jupiter.api.Test)

Example 5 with LineSeparator

use of com.lowagie.text.pdf.draw.LineSeparator in project mes by qcadoo.

the class PalletNumberHelperReportPdf method addPalletNumbers.

private void addPalletNumbers(final Document document, final List<String> numbers) throws DocumentException {
    int i = 0;
    for (String number : numbers) {
        if (i % 2 == 0) {
            Paragraph firstNumberParagraph = new Paragraph(new Phrase(number, FontUtils.getDejavuBold140Dark()));
            firstNumberParagraph.setLeading(0, 0);
            Paragraph numberSmallParagraph = new Paragraph(new Phrase(buildSmallNumber(number), FontUtils.getDejavuBold10Dark()));
            numberSmallParagraph.setLeading(0, 0);
            firstNumberParagraph.setAlignment(Element.ALIGN_CENTER);
            firstNumberParagraph.setSpacingAfter(20F);
            numberSmallParagraph.setAlignment(Element.ALIGN_CENTER);
            numberSmallParagraph.setSpacingBefore(60F);
            numberSmallParagraph.setSpacingAfter(100F);
            if (i == 0) {
                Paragraph newLineParagraph = new Paragraph(new Phrase("\n"));
                newLineParagraph.setSpacingAfter(150F);
                document.add(newLineParagraph);
            }
            document.add(firstNumberParagraph);
            document.add(numberSmallParagraph);
            LineSeparator lineSeparator = new LineSeparator(1, 100f, ColorUtils.getLineDarkColor(), Element.ALIGN_LEFT, 0);
            document.add(lineSeparator);
        }
        if (i % 2 != 0) {
            Paragraph secondNumberParagraph = new Paragraph(new Phrase(number, FontUtils.getDejavuBold140Dark()));
            Paragraph numSmallParagraph = new Paragraph(new Phrase(buildSmallNumber(number), FontUtils.getDejavuBold10Dark()));
            secondNumberParagraph.setSpacingBefore(160F);
            secondNumberParagraph.setAlignment(Element.ALIGN_CENTER);
            secondNumberParagraph.setSpacingAfter(20F);
            numSmallParagraph.setAlignment(Element.ALIGN_CENTER);
            numSmallParagraph.setSpacingBefore(60F);
            numSmallParagraph.setSpacingAfter(0F);
            secondNumberParagraph.setLeading(0, 0);
            numSmallParagraph.setLeading(0, 0);
            document.add(secondNumberParagraph);
            document.add(numSmallParagraph);
            if (i < numbers.size() - 1) {
                document.newPage();
                Paragraph newp = new Paragraph(new Phrase("\n", FontUtils.getDejavuBold10Dark()));
                newp.setSpacingAfter(150F);
                document.add(newp);
            }
        }
        i++;
    }
}
Also used : LineSeparator(com.lowagie.text.pdf.draw.LineSeparator)

Aggregations

LineSeparator (com.lowagie.text.pdf.draw.LineSeparator)9 Paragraph (com.lowagie.text.Paragraph)7 Chunk (com.lowagie.text.Chunk)4 DocumentException (com.lowagie.text.DocumentException)4 ExceptionConverter (com.lowagie.text.ExceptionConverter)4 Image (com.lowagie.text.Image)4 Phrase (com.lowagie.text.Phrase)4 File (java.io.File)3 Annotation (com.lowagie.text.Annotation)2 BadElementException (com.lowagie.text.BadElementException)2 Element (com.lowagie.text.Element)2 Font (com.lowagie.text.Font)2 ListItem (com.lowagie.text.ListItem)2 Meta (com.lowagie.text.Meta)2 Rectangle (com.lowagie.text.Rectangle)2 Section (com.lowagie.text.Section)2 Table (com.lowagie.text.Table)2 TextElementArray (com.lowagie.text.TextElementArray)2 BaseFont (com.lowagie.text.pdf.BaseFont)2 PdfPTable (com.lowagie.text.pdf.PdfPTable)2