Search in sources :

Example 16 with Text

use of com.itextpdf.layout.element.Text 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 17 with Text

use of com.itextpdf.layout.element.Text 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)17 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)17 Text (com.itextpdf.layout.element.Text)17 Paragraph (com.itextpdf.layout.element.Paragraph)16 Document (com.itextpdf.layout.Document)13 PdfFont (com.itextpdf.kernel.font.PdfFont)10 Rectangle (com.itextpdf.kernel.geom.Rectangle)5 PdfPage (com.itextpdf.kernel.pdf.PdfPage)4 PdfCanvas (com.itextpdf.kernel.pdf.canvas.PdfCanvas)4 Canvas (com.itextpdf.layout.Canvas)4 Style (com.itextpdf.layout.Style)2 SolidBorder (com.itextpdf.layout.borders.SolidBorder)2 FontProgram (com.itextpdf.io.font.FontProgram)1 PageSize (com.itextpdf.kernel.geom.PageSize)1 PdfAction (com.itextpdf.kernel.pdf.action.PdfAction)1 ColumnDocumentRenderer (com.itextpdf.layout.ColumnDocumentRenderer)1 Image (com.itextpdf.layout.element.Image)1 Link (com.itextpdf.layout.element.Link)1 List (com.itextpdf.layout.element.List)1 HyphenationConfig (com.itextpdf.layout.hyphenation.HyphenationConfig)1