Search in sources :

Example 11 with SolidBorder

use of com.itextpdf.layout.borders.SolidBorder in project i7js-highlevel by itext.

the class C05E06_CellBorders2 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.setBorder(new SolidBorder(3)).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(Border.NO_BORDER));
    table.addCell(new Cell(2, 1).add(new Paragraph("Cell with rowspan 2")).setVerticalAlignment(VerticalAlignment.MIDDLE).setBorder(Border.NO_BORDER));
    table.addCell(new Cell().add(new Paragraph("row 1; cell 1")));
    table.addCell(new Cell().add(new Paragraph("row 1; cell 2")));
    table.addCell(new Cell().add(new Paragraph("row 2; cell 1")));
    table.addCell(new Cell().add(new Paragraph("row 2; cell 2")));
    document.add(table);
    document.close();
}
Also used : Table(com.itextpdf.layout.element.Table) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) Cell(com.itextpdf.layout.element.Cell) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) SolidBorder(com.itextpdf.layout.borders.SolidBorder) Paragraph(com.itextpdf.layout.element.Paragraph)

Example 12 with SolidBorder

use of com.itextpdf.layout.borders.SolidBorder in project i7js-highlevel by itext.

the class CellProperties 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(2)).useAllAvailableWidth();
    PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
    table.addCell(new Cell().add(new Paragraph("Test 1")).setHeight(50).setDestination("Top"));
    Style style = new Style();
    style.setBackgroundColor(ColorConstants.YELLOW);
    table.addCell(new Cell().setBorder(new DottedBorder(5)).add(new Paragraph("Test 2")).addStyle(style).setRelativePosition(10, 10, 50, 10));
    table.addCell(new Cell().add(new Paragraph("Test 3")).setVerticalAlignment(VerticalAlignment.BOTTOM));
    table.addCell(new Cell().add(ParagraphProperties.getNewParagraphInstance()).setHyphenation(new HyphenationConfig("en", "uk", 3, 3)));
    table.addCell(new Cell().add(new Paragraph("Rotated")).setRotationAngle(Math.PI / 18).setFont(font).setFontSize(8).setFontColor(ColorConstants.RED));
    table.addCell(new Cell().add(new Paragraph("Centered")).setTextAlignment(TextAlignment.CENTER).setAction(PdfAction.createGoTo("Top")));
    table.addCell(new Cell().add(new Paragraph("Test 5")).setBackgroundColor(ColorConstants.BLUE));
    table.addCell(new Cell().add(ParagraphProperties.getNewParagraphInstance()).setBackgroundColor(ColorConstants.RED).setPaddingLeft(20).setPaddingRight(50));
    table.addCell(new Cell().add(new Paragraph("Test 7")).setBackgroundColor(ColorConstants.RED));
    table.addCell(new Cell().add(new Paragraph("Test 8")).setBackgroundColor(ColorConstants.BLUE).setMarginBottom(10));
    table.addCell(new Cell().add(new Paragraph("Test 9")).setBackgroundColor(ColorConstants.BLUE));
    table.addCell(new Cell().add(new Paragraph("Test 10")).setBackgroundColor(ColorConstants.RED));
    table.addCell(new Cell().add(ParagraphProperties.getNewParagraphInstance()).setBackgroundColor(ColorConstants.RED).setMargin(50).setPadding(30));
    table.addCell(new Cell().add(new Paragraph("Test 12")).setBackgroundColor(ColorConstants.BLUE));
    document.add(table);
    SolidBorder border = new SolidBorder(ColorConstants.RED, 2);
    Cell cell = new Cell().add(new Paragraph("Test")).setFixedPosition(100, 400, 350).setBorder(border).setBackgroundColor(ColorConstants.BLUE).setHeight(100).setHorizontalAlignment(HorizontalAlignment.CENTER);
    document.add(cell);
    document.close();
}
Also used : Table(com.itextpdf.layout.element.Table) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfFont(com.itextpdf.kernel.font.PdfFont) Style(com.itextpdf.layout.Style) HyphenationConfig(com.itextpdf.layout.hyphenation.HyphenationConfig) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) DottedBorder(com.itextpdf.layout.borders.DottedBorder) Cell(com.itextpdf.layout.element.Cell) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph) SolidBorder(com.itextpdf.layout.borders.SolidBorder)

Example 13 with SolidBorder

use of com.itextpdf.layout.borders.SolidBorder in project i7js-highlevel by itext.

the class TextProperties 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().setBold().setDestination("Top");
    Text t1 = new Text("Test").addStyle(style);
    document.add(new Paragraph(t1));
    Text t2 = new Text("Test").setBorder(new SolidBorder(0.5f));
    document.add(new Paragraph(t2));
    Text t3 = new Text("Test").setBorderLeft(new SolidBorder(0.5f)).setBackgroundColor(ColorConstants.LIGHT_GRAY);
    document.add(new Paragraph(t3));
    Text t4 = new Text("AWAY AGAIN").setCharacterSpacing(10);
    document.add(new Paragraph(t4));
    Text t5 = new Text("AWAY AGAIN").setWordSpacing(10);
    document.add(new Paragraph(t5));
    Text t6 = new Text("AWAY AGAIN").setRelativePosition(-10, 50, 0, 0);
    document.add(new Paragraph(t6));
    PdfAction top = PdfAction.createGoTo("Top");
    Text t7 = new Text("go to top").setAction(top);
    document.add(new Paragraph(t7));
    document.close();
}
Also used : PdfAction(com.itextpdf.kernel.pdf.action.PdfAction) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) Style(com.itextpdf.layout.Style) Text(com.itextpdf.layout.element.Text) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph) SolidBorder(com.itextpdf.layout.borders.SolidBorder)

Example 14 with SolidBorder

use of com.itextpdf.layout.borders.SolidBorder in project i7js-highlevel by itext.

the class TextWithColoredBorder method createPdf.

public void createPdf(String dest) throws IOException {
    PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
    Document document = new Document(pdf);
    document.add(new Paragraph("Paragraph with orange border").setBorder(new SolidBorder(ColorConstants.ORANGE, 5)));
    Text text = new Text("Text with orange border").setBorder(new SolidBorder(ColorConstants.ORANGE, 5));
    document.add(new Paragraph(text));
    Link link = new Link("Link with orange border", PdfAction.createURI("http://itextpdf.com"));
    link.setBorder(new SolidBorder(ColorConstants.ORANGE, 5));
    document.add(new Paragraph(link));
    document.close();
}
Also used : PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) Text(com.itextpdf.layout.element.Text) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Link(com.itextpdf.layout.element.Link) Paragraph(com.itextpdf.layout.element.Paragraph) SolidBorder(com.itextpdf.layout.borders.SolidBorder)

Aggregations

PdfDocument (com.itextpdf.kernel.pdf.PdfDocument)14 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)14 Document (com.itextpdf.layout.Document)14 SolidBorder (com.itextpdf.layout.borders.SolidBorder)14 Paragraph (com.itextpdf.layout.element.Paragraph)9 Style (com.itextpdf.layout.Style)7 AreaBreak (com.itextpdf.layout.element.AreaBreak)5 PdfFont (com.itextpdf.kernel.font.PdfFont)4 Image (com.itextpdf.layout.element.Image)4 HyphenationConfig (com.itextpdf.layout.hyphenation.HyphenationConfig)4 CsvTo2DList (com.itextpdf.highlevel.util.CsvTo2DList)3 Cell (com.itextpdf.layout.element.Cell)3 Link (com.itextpdf.layout.element.Link)3 Table (com.itextpdf.layout.element.Table)3 File (java.io.File)3 List (java.util.List)3 PdfAction (com.itextpdf.kernel.pdf.action.PdfAction)2 DottedBorder (com.itextpdf.layout.borders.DottedBorder)2 Div (com.itextpdf.layout.element.Div)2 Text (com.itextpdf.layout.element.Text)2