Search in sources :

Example 56 with Paragraph

use of com.itextpdf.layout.element.Paragraph in project digilib by robcast.

the class PDFTitlePage method createPage.

/**
 * Add the the title page to the PDF Document.
 *
 * @return
 */
public Document createPage(Document content) {
    /*
         * header with logo
         */
    Table headerBlock = new Table(UnitValue.createPercentArray(new float[] { 20, 80 }));
    Image logo = getLogo();
    if (logo != null) {
        logo.setWidth(UnitValue.createPercentValue(100));
        headerBlock.addCell(new Cell().add(logo).setBorderRight(null));
    }
    String headerText = getHeaderTitle();
    if (!headerText.isEmpty()) {
        Cell textCell = new Cell().setBorderLeft(null).setPaddingLeft(12).add(new Paragraph(headerText).setBold());
        String headerSubtext = getHeaderSubtitle();
        if (headerSubtext != null) {
            textCell.add(new Paragraph(headerSubtext));
        }
        headerBlock.addCell(textCell);
    }
    content.add(headerBlock.setMarginBottom(24));
    String reference = getReference();
    if (!reference.isEmpty()) {
        /*
             * full reference
             */
        content.add(new Paragraph(reference));
    } else {
        /*
             * author
             */
        String author = getAuthor();
        if (!author.isEmpty()) {
            content.add(new Paragraph(author).setTextAlignment(TextAlignment.CENTER));
        }
        /*
             * title
             */
        String title = getTitle();
        if (!title.isEmpty()) {
            content.add(new Paragraph(title).setTextAlignment(TextAlignment.CENTER));
        }
        /*
             * date
             */
        String date = getDate();
        if (!date.isEmpty()) {
            content.add(new Paragraph(date).setTextAlignment(TextAlignment.CENTER));
        }
    }
    /*
         * page numbers
         */
    content.add(new Paragraph(getPages()).setTextAlignment(TextAlignment.CENTER));
    /*
         * URL
         */
    try {
        content.add(new Paragraph().setTextAlignment(TextAlignment.CENTER).setFont(PdfFontFactory.createFont(StandardFonts.COURIER)).setFontSize(10).add(new Link(getUrl(), PdfAction.createURI(getUrl()))).setFixedPosition(24, 24, UnitValue.createPercentValue(98)));
    } catch (IOException e) {
        logger.error("{}", e);
    }
    return content;
}
Also used : Table(com.itextpdf.layout.element.Table) IOException(java.io.IOException) Image(com.itextpdf.layout.element.Image) Cell(com.itextpdf.layout.element.Cell) Link(com.itextpdf.layout.element.Link) Paragraph(com.itextpdf.layout.element.Paragraph)

Example 57 with Paragraph

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

the class PdfTicketBuilder method qrCode.

public PdfTicketBuilder qrCode(String code) {
    BarcodeQRCode qrcode = new BarcodeQRCode(code.trim());
    Image qrcodeImage = new Image(qrcode.createFormXObject(this.getDocument().getPdfDocument()));
    qrcodeImage.setHorizontalAlignment(HorizontalAlignment.CENTER);
    qrcodeImage.setWidthPercent(50);
    this.getDocument().add(qrcodeImage);
    Paragraph paragraph = new Paragraph("Ref. " + code);
    paragraph.setTextAlignment(TextAlignment.CENTER);
    this.getDocument().add(paragraph);
    return this;
}
Also used : BarcodeQRCode(com.itextpdf.barcodes.BarcodeQRCode) Image(com.itextpdf.layout.element.Image) Paragraph(com.itextpdf.layout.element.Paragraph)

Example 58 with Paragraph

use of com.itextpdf.layout.element.Paragraph in project ComponentManagement by Bac3Phi.

the class InventoriesReportController method addInfo.

private void addInfo(String strinfo, Document document) throws IOException {
    Paragraph info = new Paragraph(strinfo);
    // Setting font of the text
    PdfFont font = PdfFontFactory.createFont(FontConstants.TIMES_ROMAN);
    info.setFont(font);
    info.setFontSize(12);
    info.setTextAlignment(TextAlignment.LEFT);
    info.setPaddingLeft(25);
    document.add(info);
}
Also used : PdfFont(com.itextpdf.kernel.font.PdfFont) Paragraph(com.itextpdf.layout.element.Paragraph)

Example 59 with Paragraph

use of com.itextpdf.layout.element.Paragraph in project ComponentManagement by Bac3Phi.

the class ReportInventoriesController method addInfo.

private void addInfo(String strinfo, Document document) throws IOException {
    Paragraph info = new Paragraph(strinfo);
    // Setting font of the text
    info.setFont(font);
    info.setFontSize(12);
    info.setTextAlignment(TextAlignment.LEFT);
    info.setPaddingLeft(25);
    document.add(info);
}
Also used : Paragraph(com.itextpdf.layout.element.Paragraph)

Example 60 with Paragraph

use of com.itextpdf.layout.element.Paragraph in project ComponentManagement by Bac3Phi.

the class ReportInventoriesController method addDate.

private void addDate(Document document) throws IOException {
    Paragraph date;
    date = new Paragraph("Tháng: " + cbbMonth.getSelectionModel().getSelectedItem() + "/2018");
    date.setFont(font);
    date.setFontSize(12);
    date.setTextAlignment(TextAlignment.CENTER);
    document.add(date);
}
Also used : Paragraph(com.itextpdf.layout.element.Paragraph)

Aggregations

Paragraph (com.itextpdf.layout.element.Paragraph)128 PdfDocument (com.itextpdf.kernel.pdf.PdfDocument)109 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)109 Document (com.itextpdf.layout.Document)103 PdfFont (com.itextpdf.kernel.font.PdfFont)45 HyphenationConfig (com.itextpdf.layout.hyphenation.HyphenationConfig)29 BufferedReader (java.io.BufferedReader)26 FileReader (java.io.FileReader)26 Table (com.itextpdf.layout.element.Table)22 Cell (com.itextpdf.layout.element.Cell)21 AreaBreak (com.itextpdf.layout.element.AreaBreak)20 Image (com.itextpdf.layout.element.Image)20 List (java.util.List)17 CsvTo2DList (com.itextpdf.highlevel.util.CsvTo2DList)16 Text (com.itextpdf.layout.element.Text)16 Rectangle (com.itextpdf.kernel.geom.Rectangle)15 PdfCanvas (com.itextpdf.kernel.pdf.canvas.PdfCanvas)14 Tab (com.itextpdf.layout.element.Tab)13 ArrayList (java.util.ArrayList)13 TabStop (com.itextpdf.layout.element.TabStop)12