Example usage for com.lowagie.text.pdf PdfPCell setImage

List of usage examples for com.lowagie.text.pdf PdfPCell setImage

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfPCell setImage.

Prototype

public void setImage(Image image) 

Source Link

Document

Setter for property image.

Usage

From source file:com.songbook.pc.exporter.PdfExporter.java

License:Open Source License

private Element buildQrCodeSection() throws IOException, DocumentException {
    // Load images
    Image qrApkImage = PngImage//from ww w  .j  a v a  2  s .c  o m
            .getImage(PdfExporter.class.getResourceAsStream("/export/qr/songbook_apk_qr.png"));
    Image qrPdfImage = PngImage
            .getImage(PdfExporter.class.getResourceAsStream("/export/qr/songbook_pdf_qr.png"));

    PdfPCell cell = new PdfPCell((Phrase) null);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);

    PdfPTable table = new PdfPTable(3);
    table.setWidthPercentage(100);
    table.setWidths(new float[] { 1, 2, 1 });

    cell.setImage(qrApkImage);
    table.addCell(cell);
    cell.setImage(null);

    table.addCell(cell);

    cell.setImage(qrPdfImage);
    table.addCell(cell);
    cell.setImage(null);

    cell.setPhrase(new Phrase("APP"));
    table.addCell(cell);
    cell.setPhrase(null);

    table.addCell(cell);

    cell.setPhrase(new Phrase("PDF"));
    table.addCell(cell);
    cell.setPhrase(null);

    return table;
}