use of com.itextpdf.layout.borders.SolidBorder in project i7js-highlevel by itext.
the class C04E01_DivExample1 method createPdf.
public void createPdf(String dest) throws IOException {
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
Document document = new Document(pdf);
List<List<String>> resultSet = CsvTo2DList.convert(SRC, "|");
resultSet.remove(0);
for (List<String> record : resultSet) {
Div div = new Div().setBorderLeft(new SolidBorder(2)).setPaddingLeft(3).setMarginBottom(10);
String url = String.format("http://www.imdb.com/title/tt%s", record.get(0));
Link movie = new Link(record.get(2), PdfAction.createURI(url));
div.add(new Paragraph(movie.setFontSize(14))).add(new Paragraph(String.format("Directed by %s (%s, %s)", record.get(3), record.get(4), record.get(1))));
File file = new File(String.format("src/main/resources/img/%s.jpg", record.get(0)));
if (file.exists()) {
Image img = new Image(ImageDataFactory.create(file.getPath()));
img.scaleToFit(10000, 120);
div.add(img);
}
document.add(div);
}
document.close();
}
use of com.itextpdf.layout.borders.SolidBorder in project i7js-highlevel by itext.
the class C04E03_LineSeparatorExample method createPdf.
public void createPdf(String dest) throws IOException {
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
Document document = new Document(pdf);
SolidLine line = new SolidLine(1f);
line.setColor(ColorConstants.RED);
LineSeparator ls = new LineSeparator(line);
ls.setWidth(UnitValue.createPercentValue(50));
ls.setMarginTop(5);
List<List<String>> resultSet = CsvTo2DList.convert(SRC, "|");
resultSet.remove(0);
for (List<String> record : resultSet) {
String url = String.format("http://www.imdb.com/title/tt%s", record.get(0));
Link movie = new Link(record.get(2), PdfAction.createURI(url));
Div div = new Div().setKeepTogether(true).setBorderLeft(new SolidBorder(2)).setPaddingLeft(3).setMarginBottom(10).add(new Paragraph(movie.setFontSize(14f))).add(new Paragraph(String.format("Directed by %s (%s, %s)", record.get(3), record.get(4), record.get(1))));
File file = new File(String.format("src/main/resources/img/%s.jpg", record.get(0)));
if (file.exists()) {
Image img = new Image(ImageDataFactory.create(file.getPath()));
img.scaleToFit(10000, 120);
div.add(img);
}
div.add(ls);
document.add(div);
}
document.close();
}
use of com.itextpdf.layout.borders.SolidBorder in project i7js-highlevel by itext.
the class C05E06_CellBorders1 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)).setHorizontalAlignment(HorizontalAlignment.CENTER).setTextAlignment(TextAlignment.CENTER);
table.addCell(new Cell(1, 3).add(new Paragraph("Cell with colspan 3")).setVerticalAlignment(VerticalAlignment.MIDDLE).setBorder(new DashedBorder(0.5f)));
table.addCell(new Cell(2, 1).add(new Paragraph("Cell with rowspan 2")).setVerticalAlignment(VerticalAlignment.MIDDLE).setBorderBottom(new DottedBorder(0.5f)).setBorderLeft(new DottedBorder(0.5f)));
table.addCell(new Cell().add(new Paragraph("row 1; cell 1")).setBorder(new DottedBorder(ColorConstants.ORANGE, 0.5f)));
table.addCell(new Cell().add(new Paragraph("row 1; cell 2")));
table.addCell(new Cell().add(new Paragraph("row 2; cell 1")).setBorderBottom(new SolidBorder(2)));
table.addCell(new Cell().add(new Paragraph("row 2; cell 2")).setBorderBottom(new SolidBorder(2)));
document.add(table);
document.close();
}
use of com.itextpdf.layout.borders.SolidBorder in project i7js-highlevel by itext.
the class C04E02_DivExample2 method createPdf.
public void createPdf(String dest) throws IOException {
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
Document document = new Document(pdf);
List<List<String>> resultSet = CsvTo2DList.convert(SRC, "|");
resultSet.remove(0);
for (List<String> record : resultSet) {
Div div = new Div().setKeepTogether(true).setBorderLeft(new SolidBorder(2)).setPaddingLeft(3).setMarginBottom(10);
String url = String.format("http://www.imdb.com/title/tt%s", record.get(0));
Link movie = new Link(record.get(2), PdfAction.createURI(url));
div.add(new Paragraph(movie.setFontSize(14))).add(new Paragraph(String.format("Directed by %s (%s, %s)", record.get(3), record.get(4), record.get(1))));
File file = new File(String.format("src/main/resources/img/%s.jpg", record.get(0)));
if (file.exists()) {
Image img = new Image(ImageDataFactory.create(file.getPath()));
img.scaleToFit(10000, 120);
div.add(img);
}
document.add(div);
}
document.close();
}
use of com.itextpdf.layout.borders.SolidBorder in project i7js-highlevel by itext.
the class ImageProperties method createPdf.
public void createPdf(String dest) throws IOException {
// Initialize PDF document
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
Document document = new Document(pdf);
Image img1 = new Image(ImageDataFactory.create(TEST1));
img1.scaleToFit(100, 100).setDestination("Top");
document.add(img1);
Image img2 = new Image(ImageDataFactory.create(TEST2));
img2.setHeight(300);
document.add(img2);
Image img3 = new Image(ImageDataFactory.create(TEST3));
img3.scaleToFit(100, 100);
img3.setBackgroundColor(ColorConstants.BLUE);
document.add(img3);
Image img4 = new Image(ImageDataFactory.create(TEST4));
img4.scaleToFit(100, 100);
img4.setBackgroundColor(ColorConstants.RED);
document.add(img4);
Image img5 = new Image(ImageDataFactory.create(TEST5));
img5.scaleToFit(50, 50);
Style style = new Style();
style.setBorderRight(new SolidBorder(2));
img5.addStyle(style);
document.add(img5);
Image img6 = new Image(ImageDataFactory.create(TEST6));
PdfAction top = PdfAction.createGoTo("Top");
img6.scaleToFit(100, 100).setAction(top);
document.add(img6);
document.close();
}
Aggregations