use of com.itextpdf.layout.element.Paragraph in project ComponentManagement by Bac3Phi.
the class InventoriesReportController method addHeader.
private void addHeader(String strheader, Document document) throws IOException {
Paragraph header = new Paragraph(strheader);
// Setting font of the text
PdfFont font = PdfFontFactory.createFont(FontConstants.TIMES_BOLD);
header.setFont(font);
header.setFontSize(14);
header.setTextAlignment(TextAlignment.LEFT);
document.add(header);
}
use of com.itextpdf.layout.element.Paragraph in project java-example by saxingz.
the class A0025PdfApplication method addText1.
private static void addText1(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("I want to believe").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(String.valueOf(i)).showText(" of ").showText(String.valueOf(totalPage)).endText();
// Draw watermark
Paragraph p = new Paragraph("wechat-diyicaizi").setFontSize(60);
canvas.saveState();
PdfExtGState gs1 = new PdfExtGState().setFillOpacity(0.2f);
canvas.setExtGState(gs1);
document.showTextAligned(p, pageSize.getWidth() / 2, pageSize.getHeight() / 2, pdfDoc.getPageNumber(page), TextAlignment.CENTER, VerticalAlignment.MIDDLE, 45);
canvas.restoreState();
}
use of com.itextpdf.layout.element.Paragraph in project spring-learning by moon-zhou.
the class Demo002 method createPdf.
public void createPdf(String dest) throws IOException {
// Initialize PDF writer
PdfWriter writer = new PdfWriter(dest);
// Initialize PDF document
PdfDocument pdf = new PdfDocument(writer);
// Initialize document
Document document = new Document(pdf);
// Create a PdfFont
PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
// Add a Paragraph
document.add(new Paragraph("iText is:").setFont(font));
// Create a List
List list = new List().setSymbolIndent(12).setListSymbol("\u2022").setFont(font);
// Add ListItem objects
list.add(new ListItem("Never gonna give you up")).add(new ListItem("Never gonna let you down")).add(new ListItem("Never gonna run around and desert you")).add(new ListItem("Never gonna make you cry")).add(new ListItem("Never gonna say goodbye")).add(new ListItem("Never gonna tell a lie and hurt you"));
// Add the list
document.add(list);
// Close document
document.close();
}
use of com.itextpdf.layout.element.Paragraph in project ISPP by josdomqui.
the class PaymentService method generateRecipt.
public String generateRecipt(Double price) {
String fileName = "recipt.pdf";
try {
File file = new File(fileName);
PdfWriter pdfWriter = new PdfWriter(file);
PdfDocument pdfDocument = new PdfDocument(pdfWriter);
Document document = new Document(pdfDocument);
Paragraph paragraph = new Paragraph("Su pedido ha costado " + price + " euros.");
document.add(paragraph);
document.close();
pdfWriter.close();
System.out.println("PDF creado");
} catch (FileNotFoundException ex) {
System.out.println(ex.getMessage());
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
return fileName;
}
use of com.itextpdf.layout.element.Paragraph in project Rolls-Royce by EntryDSM.
the class ApplicationPdfGenerator method generateApplicationPdf.
private byte[] generateApplicationPdf(User user, Score score) {
PdfData data = pdfDataConverter.applicationToInfo(user, score);
ByteArrayOutputStream[] outputStreams = getTemplateFileNames(user).parallelStream().map(template -> templateProcessor.convertTemplateIntoHtmlString(template, data.toMap())).map(pdfProcessor::convertHtmlToPdf).toArray(ByteArrayOutputStream[]::new);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PdfDocument mergedDocument = new PdfDocument(new PdfWriter(outputStream));
PdfMerger pdfMerger = new PdfMerger(mergedDocument);
Document document = new Document(mergedDocument);
for (ByteArrayOutputStream pdfStream : outputStreams) {
PdfDocument pdfDoc = getPdfDocument(pdfStream);
mergeDocument(pdfMerger, pdfDoc);
}
for (int i = 1; i <= mergedDocument.getNumberOfPages(); i++) {
document.showTextAligned(new Paragraph(String.format("- %s -", i)), 300, 25, i, TextAlignment.CENTER, VerticalAlignment.BOTTOM, 0);
}
document.close();
return outputStream.toByteArray();
}
Aggregations