use of com.itextpdf.layout.Style in project i7js-highlevel by itext.
the class C01E10_ReusingStyles method createPdf.
public void createPdf(String dest) throws IOException {
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
Document document = new Document(pdf);
Style normal = new Style();
PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
normal.setFont(font).setFontSize(14);
Style code = new Style();
PdfFont monospace = PdfFontFactory.createFont(StandardFonts.COURIER);
code.setFont(monospace).setFontColor(ColorConstants.RED).setBackgroundColor(ColorConstants.LIGHT_GRAY);
Paragraph p = new Paragraph();
p.add(new Text("The Strange Case of ").addStyle(normal));
p.add(new Text("Dr. Jekyll").addStyle(code));
p.add(new Text(" and ").addStyle(normal));
p.add(new Text("Mr. Hyde").addStyle(code));
p.add(new Text(".").addStyle(normal));
document.add(p);
document.close();
}
use of com.itextpdf.layout.Style 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();
}
use of com.itextpdf.layout.Style in project i7js-highlevel by itext.
the class ListProperties 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);
PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
Style style = new Style();
style.setBackgroundColor(ColorConstants.YELLOW).setTextAlignment(TextAlignment.CENTER);
document.add(createNewList().addStyle(style).setWidth(300).setHorizontalAlignment(HorizontalAlignment.CENTER).setDestination("Top"));
document.add(createNewList().setRotationAngle(Math.PI / 18).setFont(font).setFontSize(8).setFontColor(ColorConstants.RED));
document.add(createNewList().setHyphenation(new HyphenationConfig("en", "uk", 3, 3)).setBorder(new SolidBorder(0.5f)).setKeepWithNext(true));
document.add(createNewList().setKeepTogether(true).setHeight(200));
document.add(createNewList().setWidth(UnitValue.createPercentValue(50)));
document.add(createNewList().setRelativePosition(10, 10, 50, 10));
document.add(createNewList());
document.add(new AreaBreak());
document.add(createNewList().setFixedPosition(100, 400, 350).setAction(PdfAction.createGoTo("Top")));
document.add(createNewList().setBackgroundColor(ColorConstants.YELLOW).setMarginBottom(10));
document.add(createNewList().setBackgroundColor(ColorConstants.LIGHT_GRAY).setPaddingLeft(20).setPaddingRight(50));
document.add(createNewList().setBackgroundColor(ColorConstants.YELLOW));
document.add(createNewList().setBackgroundColor(ColorConstants.LIGHT_GRAY));
document.add(createNewList().setBackgroundColor(ColorConstants.YELLOW));
document.add(createNewList().setBackgroundColor(ColorConstants.LIGHT_GRAY).setMargin(50).setPadding(30));
document.add(createNewList().setBackgroundColor(ColorConstants.YELLOW));
document.add(createNewList().setBackgroundColor(ColorConstants.LIGHT_GRAY));
document.close();
}
use of com.itextpdf.layout.Style in project i7js-highlevel by itext.
the class ParagraphProperties 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 p;
PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
Style style = new Style();
style.setBackgroundColor(ColorConstants.YELLOW);
p = getNewParagraphInstance().addStyle(style).setBorder(new SolidBorder(0.5f)).setDestination("Top");
document.add(p);
p = getNewParagraphInstance();
p.setBackgroundColor(ColorConstants.GRAY).setWidth(150).setHorizontalAlignment(HorizontalAlignment.CENTER).setTextAlignment(TextAlignment.CENTER);
document.add(p);
document.add(getNewParagraphInstance().setRotationAngle(Math.PI / 18));
document.add(getNewParagraphInstance().setWidth(150).setHyphenation(new HyphenationConfig("en", "uk", 3, 3)));
document.add(getNewParagraphInstance().setHeight(120).setVerticalAlignment(VerticalAlignment.BOTTOM).setBackgroundColor(ColorConstants.YELLOW).setRelativePosition(10, 10, 50, 10));
document.add(getNewParagraphInstance().setWidth(UnitValue.createPercentValue(80)).setFont(font).setFontSize(8).setFontColor(ColorConstants.RED));
document.add(new AreaBreak());
document.add(getNewParagraphInstance().setFixedPosition(100, 400, 350).setAction(PdfAction.createGoTo("Top")));
document.add(new AreaBreak());
document.add(getNewParagraphInstance().setBackgroundColor(ColorConstants.YELLOW).setMarginBottom(10));
document.add(getNewParagraphInstance().setBackgroundColor(ColorConstants.LIGHT_GRAY).setPaddingLeft(20).setPaddingRight(50));
document.add(getNewParagraphInstance().setBackgroundColor(ColorConstants.YELLOW));
document.add(getNewParagraphInstance().setBackgroundColor(ColorConstants.LIGHT_GRAY));
document.add(getNewParagraphInstance().setBackgroundColor(ColorConstants.YELLOW));
document.add(getNewParagraphInstance().setBackgroundColor(ColorConstants.LIGHT_GRAY).setMargin(50).setPadding(30));
document.add(getNewParagraphInstance().setBackgroundColor(ColorConstants.YELLOW));
document.add(getNewParagraphInstance().setBackgroundColor(ColorConstants.LIGHT_GRAY));
document.close();
}
use of com.itextpdf.layout.Style in project i7js-highlevel by itext.
the class DivProperties 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);
Style style = new Style();
style.setBackgroundColor(ColorConstants.YELLOW).setBorder(new SolidBorder(0.5f));
document.add(createNewDiv().addStyle(style).setWidth(350).setHorizontalAlignment(HorizontalAlignment.CENTER).setTextAlignment(TextAlignment.CENTER).setDestination("Top"));
PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
document.add(createNewDiv().setRotationAngle(Math.PI / 18).setFont(font).setFontSize(8).setFontColor(ColorConstants.RED));
document.add(createNewDiv().setWidth(350).setHyphenation(new HyphenationConfig("en", "uk", 3, 3)).setKeepWithNext(true));
document.add(createNewDiv().setWidth(UnitValue.createPercentValue(70)).setKeepTogether(true));
document.add(createNewDiv().setHeight(350).setBackgroundColor(ColorConstants.YELLOW).setAction(PdfAction.createGoTo("Top")).setRelativePosition(10, 10, 50, 10));
document.add(new AreaBreak());
document.add(createNewDiv().setFixedPosition(100, 400, 350));
document.add(new AreaBreak());
document.add(createNewDiv().setBackgroundColor(ColorConstants.YELLOW).setMarginBottom(10));
document.add(createNewDiv().setBackgroundColor(ColorConstants.LIGHT_GRAY).setPaddingLeft(20).setPaddingRight(50));
document.add(createNewDiv().setBackgroundColor(ColorConstants.YELLOW));
document.add(createNewDiv().setBackgroundColor(ColorConstants.LIGHT_GRAY));
document.add(createNewDiv().setBackgroundColor(ColorConstants.YELLOW));
document.add(createNewDiv().setBackgroundColor(ColorConstants.LIGHT_GRAY).setMargin(50).setPadding(30));
document.add(createNewDiv().setBackgroundColor(ColorConstants.YELLOW));
document.add(createNewDiv().setBackgroundColor(ColorConstants.LIGHT_GRAY));
document.close();
}
Aggregations