Example usage for com.itextpdf.text.pdf.draw DottedLineSeparator DottedLineSeparator

List of usage examples for com.itextpdf.text.pdf.draw DottedLineSeparator DottedLineSeparator

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf.draw DottedLineSeparator DottedLineSeparator.

Prototype

DottedLineSeparator

Source Link

Usage

From source file:be.roots.taconic.pricingguide.service.PDFServiceImpl.java

License:Open Source License

private byte[] stampTableOfContents(byte[] pdf, Toc tableOfContents) throws IOException, DocumentException {

    try (final ByteArrayOutputStream bos = new ByteArrayOutputStream()) {

        final PdfReader reader = new PdfReader(pdf);
        final PdfStamper stamper = new PdfStamper(reader, bos);

        // stamp the named destinations
        for (int pageNumber = 1; pageNumber <= reader.getNumberOfPages(); pageNumber++) {
            stamper.addNamedDestination("page" + pageNumber, pageNumber,
                    new PdfDestination(PdfDestination.XYZ, 80f, 800f, 0));
        }/*w w  w. j ava2  s. c  o  m*/

        // create the table of contents
        final Chunk tocTitle = new Chunk("TABLE OF CONTENTS", iTextUtil.getFontTocTitle());

        int currentTocPage = tableOfContents.getFirstPageOfToc();
        int firstTocPage = currentTocPage;
        PdfContentByte canvas = stamper.getOverContent(currentTocPage);

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(tocTitle), 55, 470, 0);

        final List<TocEntry> entriesSorted = tableOfContents.getEntriesSorted();
        int tocEntryNumber = 0;
        for (TocEntry tocEntry : entriesSorted) {

            if (tocEntry.isIncludedInToc()) {
                tocEntryNumber++;

                // take the right TOC page to stamp the TOC entry on (needed for TOC's with multiple pages)
                if (tocEntryNumber == getNumberOfItemsPerTocPage(0)
                        || (tocEntryNumber > getNumberOfItemsPerTocPage(0)
                                && (tocEntryNumber - getNumberOfItemsPerTocPage(0))
                                        % getNumberOfItemsPerTocPage(currentTocPage - firstTocPage) == 0)) {
                    currentTocPage++;
                    canvas = stamper.getOverContent(currentTocPage);
                }

                Font font = iTextUtil.getFontToc();
                if (tocEntry.getLevel() == 1) {
                    font = iTextUtil.getFontTocBold();
                }

                final Phrase p = processHtmlCodes(tocEntry.getLevelString() + tocEntry.getName(), font,
                        iTextUtil.getFontTocSymbol());
                p.add(new Chunk("", iTextUtil.getFontToc()));
                if (tocEntry.isShowingPageNumber()) {
                    p.add(new Chunk(new DottedLineSeparator()));
                    p.add(new Chunk("  " + String.valueOf(tocEntry.getFinalPageNumber()),
                            iTextUtil.getFontToc()));
                }

                for (Chunk chunk : p.getChunks()) {
                    chunk.setAction(PdfAction.gotoLocalPage("page" + tocEntry.getFinalPageNumber(), false));
                }

                int y;
                if (tocEntryNumber < getNumberOfItemsPerTocPage(0)) {
                    y = 460 - (16 * (tocEntryNumber % getNumberOfItemsPerTocPage(0)));
                } else {
                    y = 680 - (16 * ((tocEntryNumber - getNumberOfItemsPerTocPage(0))
                            % getNumberOfItemsPerTocPage(currentTocPage - firstTocPage)));
                }

                final ColumnText ct = new ColumnText(canvas);
                ct.setSimpleColumn(p, 52, y, 555, 70, 0, Element.ALIGN_JUSTIFIED);
                ct.go();

            }
        }

        stamper.close();
        reader.close();

        return bos.toByteArray();

    }

}

From source file:com.kohmiho.mpsr.export.PDFGenerator.java

@SuppressWarnings("unchecked")
protected void fillColumnText(List<HashMap<String, Object>> bookmarkList, ColumnText ct, float leftIndent,
        int depth, Font font) {
    if (null != bookmarkList) {
        for (int i = 0; i < bookmarkList.size(); i++) {
            HashMap<String, Object> bookmark = bookmarkList.get(i);

            String title = (String) bookmark.get("Title");
            String pageNum = ((String) bookmark.get("Page")).split(" ")[0];
            Paragraph paragraph = null != font ? new Paragraph(title, font) : new Paragraph(title);
            // paragraph.add(new Chunk(new VerticalPositionMark()));
            paragraph.add(new Chunk(new DottedLineSeparator()));
            paragraph.add(Integer.toString((Integer.parseInt(pageNum) - 1)));
            paragraph.setIndentationLeft(leftIndent * depth);
            paragraph.setSpacingBefore(0 == depth ? 9 : 0);
            ct.addElement(paragraph);// w ww. j  av  a2  s .  co  m

            fillColumnText(((List<HashMap<String, Object>>) bookmark.get("Kids")), ct, leftIndent, depth + 1,
                    null);
        }
    }
}

From source file:control.ModificaPrestamo.java

public boolean generapdf(String path) throws DocumentException, FileNotFoundException {
    boolean estado = false;
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream(path));
    document.open();/*  w  ww . ja va  2  s . co  m*/

    Image img = null;
    try {
        img = Image.getInstance("src/img/imgen.jpg");
        img.scaleAbsolute(80f, 50f);
        img.setAbsolutePosition(470f, 750f);
        document.add(img);
    } catch (BadElementException ex) {
        Logger.getLogger(nuevoReporte.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(nuevoReporte.class.getName()).log(Level.SEVERE, null, ex);
    }

    Paragraph paragraph1 = new Paragraph("Solicitante: " + Solicitante.getText());
    Paragraph paragraph2 = new Paragraph("Proyecto: " + Proyecto.getText());
    Paragraph paragraph3 = new Paragraph(
            "Fecha y hora del prestamo: " + fecha.getText() + " " + hora.getText());
    Paragraph paragraph4 = new Paragraph("Fecha de entrega: " + fecha1.getText());

    document.add(paragraph1);
    document.add(paragraph2);
    document.add(paragraph3);
    document.add(paragraph4);
    Paragraph tmp = new Paragraph("");
    tmp.setSpacingBefore(10);
    document.add(tmp);
    PdfPTable table = new PdfPTable(4);
    table.addCell("Id Equipo");
    table.addCell("Equipo");
    table.addCell("Accesorios");
    table.addCell("Descripcion");
    Object[][] tabla = this.getTableData(tabReporte);
    for (Object[] o : tabla)
        for (Object e : o) {
            table.addCell((String) e);
        }

    document.add(table);
    System.out.println(clausula1.getText() + " " + clausula2.getText());
    Paragraph paragraph5 = new Paragraph("Clausula 1: " + clausula1.getText());
    Paragraph paragraph6 = new Paragraph("Clausula 2: " + clausula2.getText());
    document.add(paragraph5);
    document.add(paragraph6);
    tmp = new Paragraph("");
    tmp.setSpacingBefore(10);
    document.add(tmp);
    Paragraph p = new Paragraph("Firma del solicitante: ");
    p.add(new Chunk(new DottedLineSeparator()));
    p.add("   Firma del prestador: ");
    p.add(new Chunk(new DottedLineSeparator()));
    document.add(p);

    //PdfPTable firma = new PdfPTable(1);
    //firma.addCell("Firma");
    //document.add(new Paragraph(""));
    //document.add(firma);
    document.close();
    return true;
}

From source file:se.billes.pdf.renderer.model.text.DottedFillPhrase.java

License:Open Source License

@Override
public void onRender(com.itextpdf.text.Paragraph paragraph) {
    DottedLineSeparator sep = new DottedLineSeparator();
    sep.setAlignment(Element.ALIGN_LEFT);
    sep.setGap(gap);//from w  ww .  j a v a2s  .c om
    sep.setLineColor(getBaseColor());
    com.itextpdf.text.Font f = new com.itextpdf.text.Font(getBaseFont(), getFontSize());
    f.setColor(getBaseColor());
    Chunk separator = new Chunk(sep);
    separator.setFont(f);
    paragraph.add(separator);
}