Search in sources :

Example 1 with LineSeparator

use of com.itextpdf.layout.element.LineSeparator in project betca-tpv-core by miw-upm.

the class PdfCoreBuilder method line.

public PdfCoreBuilder line() {
    DottedLine separator = new DottedLine();
    separator.setGap(LINE_GAP);
    separator.setLineWidth(LINE_WIDTH);
    document.add(new LineSeparator(separator));
    return this;
}
Also used : DottedLine(com.itextpdf.kernel.pdf.canvas.draw.DottedLine) LineSeparator(com.itextpdf.layout.element.LineSeparator)

Example 2 with LineSeparator

use of com.itextpdf.layout.element.LineSeparator in project i7js-highlevel by itext.

the class JekyllHydeV5 method createPdf.

public void createPdf(String dest) throws IOException {
    // Initialize PDF document
    PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
    // Initialize document
    Document document = new Document(pdf);
    PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
    PdfFont bold = PdfFontFactory.createFont(StandardFonts.HELVETICA_BOLD);
    document.setTextAlignment(TextAlignment.JUSTIFIED).setHyphenation(new HyphenationConfig("en", "uk", 3, 3));
    BufferedReader br = new BufferedReader(new FileReader(SRC));
    LineSeparator separator = new LineSeparator(new DottedLine(2f, 5f));
    separator.setMarginLeft(10);
    separator.setMarginRight(10);
    boolean chapter = false;
    Div div = new Div();
    String line;
    while ((line = br.readLine()) != null) {
        div = new Div().setFont(font).setFontSize(11).setMarginBottom(18);
        div.add(new Paragraph(line).setFont(bold).setFontSize(12).setMarginBottom(0));
        while ((line = br.readLine()) != null) {
            div.add(new Paragraph(line).setMarginBottom(0).setFirstLineIndent(36));
            if (line.isEmpty()) {
                if (chapter) {
                    div.add(separator);
                }
                document.add(div);
                div = new Div();
                chapter = true;
                break;
            }
        }
    }
    document.add(div);
    // Close document
    document.close();
}
Also used : PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) HyphenationConfig(com.itextpdf.layout.hyphenation.HyphenationConfig) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) LineSeparator(com.itextpdf.layout.element.LineSeparator) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph) Div(com.itextpdf.layout.element.Div) DottedLine(com.itextpdf.kernel.pdf.canvas.draw.DottedLine) PdfFont(com.itextpdf.kernel.font.PdfFont) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader)

Example 3 with LineSeparator

use of com.itextpdf.layout.element.LineSeparator in project betca-tpv-spring by miw-upm.

the class PdfTicketBuilder method line.

public PdfTicketBuilder line() {
    DottedLine separator = new DottedLine();
    separator.setGap(LINE_GAP);
    separator.setLineWidth(LINE_WIDTH);
    this.getDocument().add(new LineSeparator(separator));
    return this;
}
Also used : DottedLine(com.itextpdf.kernel.pdf.canvas.draw.DottedLine) LineSeparator(com.itextpdf.layout.element.LineSeparator)

Aggregations

DottedLine (com.itextpdf.kernel.pdf.canvas.draw.DottedLine)3 LineSeparator (com.itextpdf.layout.element.LineSeparator)3 PdfFont (com.itextpdf.kernel.font.PdfFont)1 PdfDocument (com.itextpdf.kernel.pdf.PdfDocument)1 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)1 Document (com.itextpdf.layout.Document)1 Div (com.itextpdf.layout.element.Div)1 Paragraph (com.itextpdf.layout.element.Paragraph)1 HyphenationConfig (com.itextpdf.layout.hyphenation.HyphenationConfig)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1