Search in sources :

Example 6 with Div

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

the class DivProperties method createNewDiv.

public static Div createNewDiv() {
    Div div = new Div();
    div.add(ParagraphProperties.getNewParagraphInstance());
    div.add(ListSeparatorProperties.createNewSeparator());
    div.add(ListProperties.createNewList());
    return div;
}
Also used : Div(com.itextpdf.layout.element.Div)

Example 7 with Div

use of com.itextpdf.layout.element.Div 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 8 with Div

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

the class C04E04_ParagraphAndDiv1 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));
    String line;
    Div div = new Div();
    while ((line = br.readLine()) != null) {
        Paragraph title = new Paragraph(line).setFont(bold).setFontSize(12).setMarginBottom(0);
        div = new Div().add(title).setFont(font).setFontSize(11).setMarginBottom(18);
        while ((line = br.readLine()) != null) {
            div.add(new Paragraph(line).setMarginBottom(0).setFirstLineIndent(36));
            if (line.isEmpty()) {
                document.add(div);
                break;
            }
        }
    }
    document.add(div);
    // Close document
    document.close();
}
Also used : Div(com.itextpdf.layout.element.Div) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfFont(com.itextpdf.kernel.font.PdfFont) BufferedReader(java.io.BufferedReader) HyphenationConfig(com.itextpdf.layout.hyphenation.HyphenationConfig) FileReader(java.io.FileReader) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph)

Example 9 with Div

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

the class C04E05_ParagraphAndDiv3 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));
    String line;
    Div div = new Div();
    while ((line = br.readLine()) != null) {
        document.add(new Paragraph(line).setFont(bold).setFontSize(12).setMarginBottom(0).setKeepWithNext(true));
        div = new Div().setFont(font).setFontSize(11).setMarginBottom(18);
        while ((line = br.readLine()) != null) {
            div.add(new Paragraph(line).setMarginBottom(0).setFirstLineIndent(36).setMultipliedLeading(1.2f));
            if (line.isEmpty()) {
                document.add(div);
                break;
            }
        }
    }
    document.add(div);
    // Close document
    document.close();
}
Also used : Div(com.itextpdf.layout.element.Div) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfFont(com.itextpdf.kernel.font.PdfFont) BufferedReader(java.io.BufferedReader) HyphenationConfig(com.itextpdf.layout.hyphenation.HyphenationConfig) FileReader(java.io.FileReader) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph)

Example 10 with Div

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

the class JekyllHydeV6 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, PageSize.A4);
    // Set column parameters
    float offSet = 27;
    float gutter = 18;
    float columnWidth = (PageSize.A4.getWidth() - offSet * 2) / 3 - gutter;
    float columnHeight = PageSize.A4.getHeight() - offSet * 2;
    // Define column areas
    Rectangle[] columns = { new Rectangle(offSet + gutter * 0.5f, offSet, columnWidth, columnHeight), new Rectangle(offSet + columnWidth + gutter * 1.5f, offSet, columnWidth, columnHeight), new Rectangle(offSet + columnWidth * 2 + gutter * 2.5f, offSet, columnWidth, columnHeight) };
    document.setRenderer(new ColumnDocumentRenderer(document, columns));
    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));
    boolean chapter = false;
    Div div = new Div();
    AreaBreak areaBreak = new AreaBreak(AreaBreakType.NEXT_AREA);
    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()) {
                document.add(div);
                if (chapter) {
                    document.add(areaBreak);
                }
                div = new Div();
                chapter = true;
                break;
            }
        }
    }
    document.add(div);
    // Close document
    document.close();
}
Also used : PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) Rectangle(com.itextpdf.kernel.geom.Rectangle) HyphenationConfig(com.itextpdf.layout.hyphenation.HyphenationConfig) AreaBreak(com.itextpdf.layout.element.AreaBreak) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph) Div(com.itextpdf.layout.element.Div) ColumnDocumentRenderer(com.itextpdf.layout.ColumnDocumentRenderer) PdfFont(com.itextpdf.kernel.font.PdfFont) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader)

Aggregations

Div (com.itextpdf.layout.element.Div)11 PdfDocument (com.itextpdf.kernel.pdf.PdfDocument)10 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)10 Document (com.itextpdf.layout.Document)10 Paragraph (com.itextpdf.layout.element.Paragraph)10 PdfFont (com.itextpdf.kernel.font.PdfFont)8 HyphenationConfig (com.itextpdf.layout.hyphenation.HyphenationConfig)8 BufferedReader (java.io.BufferedReader)8 FileReader (java.io.FileReader)8 CsvTo2DList (com.itextpdf.highlevel.util.CsvTo2DList)2 Rectangle (com.itextpdf.kernel.geom.Rectangle)2 ColumnDocumentRenderer (com.itextpdf.layout.ColumnDocumentRenderer)2 SolidBorder (com.itextpdf.layout.borders.SolidBorder)2 AreaBreak (com.itextpdf.layout.element.AreaBreak)2 Image (com.itextpdf.layout.element.Image)2 Link (com.itextpdf.layout.element.Link)2 File (java.io.File)2 List (java.util.List)2 DottedLine (com.itextpdf.kernel.pdf.canvas.draw.DottedLine)1 LineSeparator (com.itextpdf.layout.element.LineSeparator)1