Example usage for java.lang Exception getMessage

List of usage examples for java.lang Exception getMessage

Introduction

In this page you can find the example usage for java.lang Exception getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:MultipleLinedTextPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/* w w  w . j a  v a  2  s .  c o  m*/
        PdfWriter.getInstance(document, new FileOutputStream("MultipleLinedTextPDF.pdf"));
        document.open();

        Chunk chunk;
        chunk = new Chunk("Multiple lines");
        chunk.setUnderline(new Color(0xFF, 0x00, 0x00), 0.0f, 0.3f, 0.0f, 0.4f, PdfContentByte.LINE_CAP_ROUND);
        chunk.setUnderline(new Color(0x00, 0xFF, 0x00), 3.0f, 0.0f, 0.0f, -0.5f,
                PdfContentByte.LINE_CAP_PROJECTING_SQUARE);
        chunk.setUnderline(new Color(0x00, 0x00, 0xFF), 0.0f, 0.2f, 15.0f, 0.0f, PdfContentByte.LINE_CAP_BUTT);
        document.add(chunk);

    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:AffineTransformationPDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4);
    try {//from w w  w. j  a va2  s. c  o  m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("AffineTransformationPDF.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        cb.transform(AffineTransform.getScaleInstance(1.2, 0.75));

        cb.moveTo(216, 720);
        cb.lineTo(360, 360);
        cb.lineTo(360, 504);
        cb.lineTo(72, 144);
        cb.lineTo(144, 288);
        cb.stroke();

    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:LINE_CAP_PROJECTING_SQUARE_and_LINE_CAP_BUTT.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*  w ww . ja  v  a  2  s.c  o  m*/
        PdfWriter.getInstance(document,
                new FileOutputStream("LINE_CAP_PROJECTING_SQUARE_and_LINE_CAP_BUTT.pdf"));
        document.open();

        Chunk c = new Chunk("Multiple lines", FontFactory.getFont(FontFactory.HELVETICA, 24));
        c.setUnderline(new Color(0x00, 0xFF, 0x00), 5.0f, 0.0f, 0.0f, -0.5f,
                PdfContentByte.LINE_CAP_PROJECTING_SQUARE);
        c.setUnderline(new Color(0x00, 0x00, 0xFF), 0.0f, 0.2f, 15.0f, 0.0f, PdfContentByte.LINE_CAP_BUTT);
        document.add(c);
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:FontColorByPdfContentBytePDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from   ww w .java 2s . c  o m*/
        PdfWriter writer = PdfWriter.getInstance(document,
                new FileOutputStream("FontColorByPdfContentBytePDF.pdf"));
        document.open();

        BaseFont bf = FontFactory.getFont(FontFactory.COURIER).getCalculatedBaseFont(false);
        PdfContentByte cb = writer.getDirectContent();
        cb.beginText();
        cb.setColorFill(new Color(0x00, 0xFF, 0x00));
        cb.setFontAndSize(bf, 12);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "Grass is green", 250, 700, 0);
        cb.endText();

    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:ImagesUNDERLYINGPDF.java

public static void main(java.lang.String[] args) {
    Document document = new Document();
    try {//w  ww .jav  a 2 s .c  om
        PdfWriter.getInstance(document, new FileOutputStream("ImagesUNDERLYINGPDF.pdf"));
        document.open();

        Image imageRight = Image.getInstance("logo.png");
        imageRight.setAlignment(Image.UNDERLYING);

        for (int i = 0; i < 100; i++) {
            document.add(new Phrase("Text "));
        }
        document.add(imageRight);
        for (int i = 0; i < 100; i++) {
            document.add(new Phrase("Text "));
        }
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:ImagesDefaultWRAPPDF.java

public static void main(java.lang.String[] args) {
    Document document = new Document();
    try {/*from w ww.  j  a v a  2 s .c  o  m*/
        PdfWriter.getInstance(document, new FileOutputStream("ImagesDefaultWRAPPDF.pdf"));
        document.open();

        Image imageRight = Image.getInstance("logo.png");
        imageRight.setAlignment(Image.LEFT);

        for (int i = 0; i < 100; i++) {
            document.add(new Phrase("Text "));
        }
        document.add(imageRight);
        for (int i = 0; i < 100; i++) {
            document.add(new Phrase("Text "));
        }
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:RenderingTEXT_RENDER_MODE_FILL.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from  w w w .java2 s  . c o m
        PdfWriter.getInstance(document, new FileOutputStream("RenderingTEXT_RENDER_MODE_FILL.pdf"));

        document.open();

        Paragraph p = new Paragraph("Text Rendering:");
        document.add(p);
        Chunk chunk = new Chunk("rendering test");
        chunk.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_FILL, 100f, new Color(0xFF, 0x00, 0x00));
        document.add(chunk);

    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:TableWithImagePDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {// w ww.j  av  a  2s  .c om
        PdfWriter.getInstance(document, new FileOutputStream("TableWithImagePDF.pdf"));

        document.open();

        Table table = new Table(1);
        table.addCell(new Cell(Image.getInstance("logo.png")));
        Cell c1 = new Cell();
        c1.add(Image.getInstance("logo.png"));
        table.addCell(c1);

        document.add(table);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:LayerImageOnTextPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from www  . j  a va 2  s. co m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("LayerImageOnTextPDF.pdf"));
        document.open();

        Paragraph p = new Paragraph();
        for (int i = 0; i < 100; i++)
            p.add(new Chunk("Text Text Text Text Text Text Text Text "));
        document.add(p);

        Image img = Image.getInstance("logo.png");
        img.setAbsolutePosition(100, 500);
        document.add(img);

    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:RenderingTEXT_RENDER_MODE_FILL_STROKE5.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from  www. j  a  v a  2s .com*/
        PdfWriter.getInstance(document, new FileOutputStream("RenderingTEXT_RENDER_MODE_FILL_STROKE5.pdf"));

        document.open();

        Paragraph p = new Paragraph("Text Rendering:");
        document.add(p);
        Chunk chunk = new Chunk("rendering test");
        chunk.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE, 0.5f, new Color(0x00, 0x00, 0x00));
        document.add(chunk);

    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}