use of com.itextpdf.layout.Document 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.Document 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();
}
use of com.itextpdf.layout.Document in project i7js-highlevel by itext.
the class C03E17_MaryReillyV10 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: ");
Image img = new Image(ImageDataFactory.create(MARY));
img.scale(0.5f, 0.5f);
img.setRotationAngle(-Math.PI / 6);
p.add(img);
document.add(p);
document.close();
}
use of com.itextpdf.layout.Document in project i7js-highlevel by itext.
the class C04E06_CustomParagraph 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);
Paragraph p1 = new Paragraph("The Strange Case of Dr. Jekyll and Mr. Hyde");
p1.setBackgroundColor(ColorConstants.ORANGE);
document.add(p1);
Paragraph p2 = new Paragraph("The Strange Case of Dr. Jekyll and Mr. Hyde");
p2.setBackgroundColor(ColorConstants.ORANGE);
p2.setNextRenderer(new MyParagraphRenderer(p2));
document.add(p2);
document.close();
}
use of com.itextpdf.layout.Document in project i7js-highlevel by itext.
the class C01E02_Text_Paragraph_Cardo 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);
// Add content
FontProgram fontProgram = FontProgramFactory.createFont(REGULAR);
PdfFont font = PdfFontFactory.createFont(fontProgram, PdfEncodings.WINANSI, EmbeddingStrategy.PREFER_EMBEDDED);
PdfFont bold = PdfFontFactory.createFont(BOLD, PdfEncodings.WINANSI, EmbeddingStrategy.PREFER_EMBEDDED);
PdfFont italic = PdfFontFactory.createFont(ITALIC, PdfEncodings.WINANSI, EmbeddingStrategy.PREFER_EMBEDDED);
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().setFont(italic).add(title).add(" by ").add(author);
document.add(p);
// Close document
document.close();
}
Aggregations