use of com.itextpdf.layout.element.Paragraph in project i7js-highlevel by itext.
the class C02E03_CanvasRepeat method createPdf.
public void createPdf(String dest) throws IOException {
// Initialize PDF document
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
PdfPage page = pdf.addNewPage();
PdfCanvas pdfCanvas = new PdfCanvas(page);
Rectangle rectangle = new Rectangle(36, 500, 100, 250);
pdfCanvas.rectangle(rectangle);
pdfCanvas.stroke();
Canvas canvas = new Canvas(pdfCanvas, rectangle);
MyCanvasRenderer renderer = new MyCanvasRenderer(canvas);
canvas.setRenderer(renderer);
PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
PdfFont bold = PdfFontFactory.createFont(StandardFonts.TIMES_BOLD);
Text title = new Text("The Strange Case of Dr. Jekyll and Mr. Hyde").setFont(bold);
Text author = new Text("Robert Louis Stevenson").setFont(font);
Paragraph p = new Paragraph().add(title).add(" by ").add(author);
while (!renderer.isFull()) canvas.add(p);
canvas.close();
// Close document
pdf.close();
}
use of com.itextpdf.layout.element.Paragraph in project i7js-highlevel by itext.
the class C02E05_JekyllHydeV1 method createPdf.
public void createPdf(String dest) throws IOException {
// Initialize PDF document
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
// Initialize document
Document document = new Document(pdf);
BufferedReader br = new BufferedReader(new FileReader(SRC));
String line;
while ((line = br.readLine()) != null) {
document.add(new Paragraph(line));
}
br.close();
// Close document
document.close();
}
use of com.itextpdf.layout.element.Paragraph in project i7js-highlevel by itext.
the class C05E02_ColumnWidths2 method createPdf.
public void createPdf(String dest) throws IOException {
// Initialize PDF document
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
// Initialize document
Document document = new Document(pdf);
Table table = new Table(UnitValue.createPercentArray(new float[] { 1, 1, 1 }));
table.addCell(new Cell(1, 3).add(new Paragraph("Cell with colspan 3")));
table.addCell(new Cell(2, 1).add(new Paragraph("Cell with rowspan 2")));
table.addCell("row 1; cell 1");
table.addCell("row 1; cell 2");
table.addCell("row 2; cell 1");
table.addCell("row 2; cell 2");
document.add(table);
document.close();
}
use of com.itextpdf.layout.element.Paragraph in project i7js-highlevel by itext.
the class C05E03_CellAlignment method createPdf.
public void createPdf(String dest) throws IOException {
// Initialize PDF document
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
// Initialize document
Document document = new Document(pdf);
Table table = new Table(UnitValue.createPercentArray(new float[] { 2, 1, 1 }));
table.setWidth(UnitValue.createPercentValue(80));
table.setHorizontalAlignment(HorizontalAlignment.CENTER);
table.setTextAlignment(TextAlignment.CENTER);
table.addCell(new Cell(1, 3).add(new Paragraph("Cell with colspan 3")));
table.addCell(new Cell(2, 1).add(new Paragraph("Cell with rowspan 2")).setTextAlignment(TextAlignment.RIGHT));
table.addCell("row 1; cell 1");
table.addCell("row 1; cell 2");
table.addCell("row 2; cell 1");
table.addCell("row 2; cell 2");
Cell cell = new Cell().add(new Paragraph("Left").setTextAlignment(TextAlignment.LEFT)).add(new Paragraph("Center")).add(new Paragraph("Right").setTextAlignment(TextAlignment.RIGHT));
table.addCell(cell);
cell = new Cell().add(new Paragraph("Middle")).setVerticalAlignment(VerticalAlignment.MIDDLE);
table.addCell(cell);
cell = new Cell().add(new Paragraph("Bottom")).setVerticalAlignment(VerticalAlignment.BOTTOM);
table.addCell(cell);
document.add(table);
document.close();
}
use of com.itextpdf.layout.element.Paragraph in project i7js-highlevel by itext.
the class C03E13_MaryReillyV6 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.setFixedPosition(2, 300, 750, UnitValue.createPointValue(50));
document.add(img);
document.close();
}
Aggregations