use of com.itextpdf.layout.element.Image in project betca-tpv-spring by miw-upm.
the class PdfTag24Builder method addTag24.
public PdfTag24Builder addTag24(String description, String code) {
assert description != null;
assert code != null;
if ((tag24 % 24) == 0) {
if (tag24 > 0) {
this.getDocument().add(new AreaBreak(AreaBreakType.NEXT_PAGE));
}
this.prepareTags24();
}
Cell cell = new Cell();
cell.setPaddingTop(10);
cell.setMinHeight(84.2F);
cell.setBorder(Border.NO_BORDER);
cell.setTextAlignment(TextAlignment.CENTER);
cell.add(description);
if (!code.isEmpty()) {
BarcodeEAN barcode = new BarcodeEAN(this.getDocument().getPdfDocument());
barcode.setCodeType(BarcodeEAN.EAN13);
barcode.setCode(code.trim());
Image barcodeImage = new Image(barcode.createFormXObject(this.getDocument().getPdfDocument()));
barcodeImage.setWidthPercent(70);
barcodeImage.setHorizontalAlignment(HorizontalAlignment.CENTER);
cell.add(barcodeImage);
}
this.getTable().addCell(cell);
this.getDocument().add(this.getTable());
tag24++;
return this;
}
use of com.itextpdf.layout.element.Image in project betca-tpv-core by miw-upm.
the class PdfCoreBuilder method barcode.
public PdfCoreBuilder barcode(String code) {
if (code.length() > 12) {
code = code.substring(code.length() - 12);
}
Barcode128 code128 = new Barcode128(this.document.getPdfDocument());
code128.setCodeType(Barcode128.CODE128);
// UTF8
code128.setCode(code.trim().replace('-', '/').replace('_', '?'));
code128.setAltText(code.trim());
Image code128Image = new Image(code128.createFormXObject(this.document.getPdfDocument()));
code128Image.setWidthPercent(BARCODE_WIDTH);
code128Image.setHeight(BARCODE_HEIGHT);
code128Image.setHorizontalAlignment(HorizontalAlignment.CENTER);
this.document.add(code128Image);
return this;
}
use of com.itextpdf.layout.element.Image in project commons by mosip.
the class PDFGeneratorImpl method asPDF.
/*
* (non-Javadoc)
*
* @see io.mosip.kernel.core.pdfgenerator.spi.PDFGenerator#asPDF(java.util.List)
*/
@Override
public byte[] asPDF(List<BufferedImage> bufferedImages) throws IOException {
byte[] scannedPdfFile = null;
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
PdfWriter pdfWriter = new PdfWriter(byteArrayOutputStream);
Document document = new Document(new PdfDocument(pdfWriter));
for (BufferedImage bufferedImage : bufferedImages) {
Image image = new Image(ImageDataFactory.create(getImageBytesFromBufferedImage(bufferedImage)));
image.scaleToFit(600, 750);
document.add(image);
}
document.close();
pdfWriter.close();
scannedPdfFile = byteArrayOutputStream.toByteArray();
} catch (IOException e) {
throw new PDFGeneratorException(PDFGeneratorExceptionCodeConstant.PDF_EXCEPTION.getErrorCode(), e.getMessage());
}
return scannedPdfFile;
}
use of com.itextpdf.layout.element.Image in project i7js-highlevel by itext.
the class C03E10_MaryReillyV3 method createPdf.
public void createPdf(String dest) throws IOException {
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
Document document = new Document(pdf);
Paragraph p = new Paragraph("Mary Reilly is a maid in the household of Dr. Jekyll: ");
document.add(p);
Image img1 = new Image(ImageDataFactory.create(MARY));
document.add(img1);
Image img2 = new Image(ImageDataFactory.create(MARY));
document.add(img2);
document.close();
}
use of com.itextpdf.layout.element.Image in project i7js-highlevel by itext.
the class C03E18_ImageTypes method createPdf.
public void createPdf(String dest) throws IOException {
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
Document document = new Document(pdf);
// raw
byte[] data = new byte[256 * 3];
for (int i = 0; i < 256; i++) {
data[i * 3] = (byte) (255 - i);
data[i * 3 + 1] = (byte) (255 - i);
data[i * 3 + 2] = (byte) i;
}
ImageData raw = ImageDataFactory.create(256, 1, 3, 8, data, null);
Image img = new Image(raw);
img.scaleAbsolute(256, 10);
document.add(img);
// JPEG2000
Image img1 = new Image(ImageDataFactory.create(TEST1));
document.add(img1);
document.add(new AreaBreak());
// BMP
Image img2 = new Image(ImageDataFactory.create(TEST2));
img2.setMarginBottom(10);
document.add(img2);
// PNG
Image img3 = new Image(ImageDataFactory.create(TEST3));
img3.setMarginBottom(10);
document.add(img3);
// Transparent PNG
Image img4 = new Image(ImageDataFactory.create(TEST4));
img4.setBorderLeft(new SolidBorder(6));
document.add(img4);
// GIF
Image img5 = new Image(ImageDataFactory.create(TEST5));
img5.setBackgroundColor(ColorConstants.LIGHT_GRAY);
document.add(img5);
// AWT
java.awt.Image awtImage = Toolkit.getDefaultToolkit().createImage(TEST5);
Image awt = new Image(ImageDataFactory.create(awtImage, java.awt.Color.yellow));
awt.setMarginTop(10);
document.add(awt);
// JBIG2
Image img6 = new Image(ImageDataFactory.create(TEST6));
document.add(img6);
// TIFF
Image img7 = new Image(ImageDataFactory.create(TEST7));
document.add(img7);
document.close();
}
Aggregations