use of com.itextpdf.layout.element.Image 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;
}
use of com.itextpdf.layout.element.Image in project betca-tpv-spring by miw-upm.
the class PdfTicketBuilder method addImage.
public PdfTicketBuilder addImage(String fileName) {
try {
Image img = new Image(ImageDataFactory.create(this.absolutePathOfResource("img/" + fileName)));
img.setWidth(IMAGE_WIDTH);
img.setHorizontalAlignment(HorizontalAlignment.CENTER);
this.getDocument().add(img);
} catch (MalformedURLException mue) {
Logger.getLogger(this.getClass()).error("File: " + mue);
}
return this;
}
use of com.itextpdf.layout.element.Image 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;
}
use of com.itextpdf.layout.element.Image in project MtgDesktopCompanion by nicho92.
the class PDFExport method createCell.
private Cell createCell(MagicCard card) throws IOException {
ImageData imageData = null;
try {
imageData = ImageDataFactory.create(getEnabledPlugin(MTGPictureProvider.class).getFullSizePicture(card), null);
} catch (Exception e) {
imageData = ImageDataFactory.create(getEnabledPlugin(MTGPictureProvider.class).getBackPicture(), null);
}
var image = new Image(imageData);
image.scaleAbsolute(2.49f * userPoint, 3.48f * userPoint);
var cell = new Cell();
if (getBoolean("PRINT_CUT_LINE")) {
cell.setBorder(new DottedBorder(0.5f));
} else
cell.setBorder(Border.NO_BORDER);
if (getInt(SPACE) != null)
cell.setPadding(getInt(SPACE));
cell.add(image);
return cell;
}
use of com.itextpdf.layout.element.Image in project betca-tpv-spring by miw-upm.
the class PdfTicketBuilder method barCode.
public PdfTicketBuilder barCode(String code) {
Barcode128 code128 = new Barcode128(this.getDocument().getPdfDocument());
code128.setCodeType(Barcode128.CODE128);
code128.setCode(code.trim());
Image code128Image = new Image(code128.createFormXObject(this.getDocument().getPdfDocument()));
int width = code.length() * 7;
if (width > 100) {
width = 100;
}
code128Image.setWidthPercent(width);
code128Image.setHorizontalAlignment(HorizontalAlignment.CENTER);
this.getDocument().add(code128Image);
return this;
}
Aggregations