SimpleTable with QR code
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package tutorial.chapter01;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.itextpdf.barcodes.BarcodeQRCode;
|
||||
import com.itextpdf.kernel.pdf.PdfDocument;
|
||||
import com.itextpdf.kernel.pdf.PdfWriter;
|
||||
import com.itextpdf.layout.Document;
|
||||
import com.itextpdf.layout.element.Image;
|
||||
import com.itextpdf.layout.element.Table;
|
||||
|
||||
public class SimpleTable {
|
||||
public static final String DEST = "results/simple_table.pdf";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
File file = new File(DEST);
|
||||
file.getParentFile().mkdirs();
|
||||
new SimpleTable().manipulatePdf(DEST);
|
||||
}
|
||||
|
||||
protected void manipulatePdf(String dest) throws Exception {
|
||||
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest));
|
||||
Document doc = new Document(pdfDoc);
|
||||
|
||||
Table table = new Table(9);
|
||||
for (int i = 0; i < 17; i++) {
|
||||
table.addCell("hi");
|
||||
}
|
||||
|
||||
BarcodeQRCode barcodeQRCode = new BarcodeQRCode("spotify:album:1X2HXE2lAqdmD8VjiBX8Tn");
|
||||
table.addCell(new Image(barcodeQRCode.createFormXObject(pdfDoc)));
|
||||
|
||||
doc.add(table);
|
||||
|
||||
doc.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user