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;
}
use of com.itextpdf.layout.element.Paragraph in project betca-tpv-core by miw-upm.
the class PdfCoreBuilder method qrCode.
public PdfCoreBuilder qrCode(String code) {
BarcodeQRCode barcodeQRCode = new BarcodeQRCode(code.trim());
Image qcCodeImage = new Image(barcodeQRCode.createFormXObject(this.document.getPdfDocument()));
qcCodeImage.setHorizontalAlignment(HorizontalAlignment.CENTER);
qcCodeImage.setWidthPercent(QR_CODE_PERCENT);
this.document.add(qcCodeImage);
Paragraph paragraph = new Paragraph(code);
paragraph.setTextAlignment(TextAlignment.CENTER);
this.document.add(paragraph);
return this;
}
use of com.itextpdf.layout.element.Paragraph in project java-example by saxingz.
the class A0025PdfApplication method addText2.
private static void addText2(PdfCanvas canvas, Rectangle pageSize, int totalPage, int i, Document document, PdfDocument pdfDoc, PdfPage page) throws IOException {
// Draw header text
canvas.beginText().setFontAndSize(PdfFontFactory.createFont(FontConstants.HELVETICA), 7).moveText(pageSize.getWidth() / 2 - 24, pageSize.getHeight() - 10).showText(randomStr() + WECHAT_STR + randomStr()).endText();
// Draw footer line
canvas.setStrokeColor(Color.BLACK).setLineWidth(.2f).moveTo(pageSize.getWidth() / 2 - 30, 20).lineTo(pageSize.getWidth() / 2 + 30, 20).stroke();
// Draw page number
canvas.beginText().setFontAndSize(PdfFontFactory.createFont(FontConstants.HELVETICA), 7).moveText(pageSize.getWidth() / 2 - 7, 10).showText(randomStr() + WECHAT_STR + randomStr()).endText();
int waterTimes = randomInt(WATER_TIMES_RANGE);
System.out.println("本页水印: " + waterTimes + "层");
for (int j = 0; j < waterTimes; j++) {
// Draw watermark
Paragraph p = new Paragraph(WECHAT_STR).setFontSize(randomInt(WATER_FONT_SIZE_RANGE));
PdfExtGState gs1 = new PdfExtGState().setFillOpacity(WATER_OPACITY);
canvas.setExtGState(gs1);
document.showTextAligned(p, pageSize.getWidth() / WATER_POSITION_RANGE * randomInt(WATER_POSITION_RANGE), pageSize.getHeight() / WATER_POSITION_RANGE * randomInt(WATER_POSITION_RANGE), pdfDoc.getPageNumber(page), TextAlignment.CENTER, VerticalAlignment.MIDDLE, randomInt(360));
// add random char
Paragraph p2 = new Paragraph(getRandomWechat(WECHAT_STR)).setFontSize(randomInt(WATER_FONT_SIZE_RANGE));
PdfExtGState gs2 = new PdfExtGState().setFillOpacity(WATER_OPACITY);
canvas.setExtGState(gs2);
document.showTextAligned(p2, pageSize.getWidth() / WATER_POSITION_RANGE * randomInt(WATER_POSITION_RANGE), pageSize.getHeight() / WATER_POSITION_RANGE * randomInt(WATER_POSITION_RANGE), pdfDoc.getPageNumber(page), TextAlignment.CENTER, VerticalAlignment.MIDDLE, randomInt(360));
// transparent
Paragraph p3 = new Paragraph(WECHAT_STR).setFontSize(randomInt(WATER_FONT_SIZE_RANGE));
PdfExtGState gs3 = new PdfExtGState().setFillOpacity(0);
canvas.setExtGState(gs3);
document.showTextAligned(p3, pageSize.getWidth() / WATER_POSITION_RANGE * randomInt(WATER_POSITION_RANGE), pageSize.getHeight() / WATER_POSITION_RANGE * randomInt(WATER_POSITION_RANGE), pdfDoc.getPageNumber(page), TextAlignment.CENTER, VerticalAlignment.MIDDLE, randomInt(360));
}
canvas.saveState();
canvas.restoreState();
}
use of com.itextpdf.layout.element.Paragraph in project spring-learning by moon-zhou.
the class Demo001 method main.
public static void main(String[] args) {
try {
String dest = "/Users/xxx/tmp/pdf/demo001.pdf";
PdfWriter writer = new PdfWriter(dest);
PdfDocument pdf = new PdfDocument(writer);
Document document = new Document(pdf);
document.add(new Paragraph("Hello World!"));
document.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
use of com.itextpdf.layout.element.Paragraph in project i7js-highlevel by itext.
the class C03E15_MaryReillyV8 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 img = new Image(ImageDataFactory.create(MARY));
img.setHorizontalAlignment(HorizontalAlignment.CENTER);
img.setWidth(UnitValue.createPercentValue(80));
document.add(img);
document.close();
}
Aggregations