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:PDFListsAtoE.java

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

        Paragraph paragraph = new Paragraph("A to E:");
        List list = new List(false, 10);
        list.add("A");
        list.add("B");
        list.add("C");
        list.add("D");
        list.add("E");
        paragraph.add(list);
        document.add(paragraph);
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:FormComboPDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4);

    try {/*from   ww w  . ja v  a  2 s.c  o  m*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("FormComboPDF.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        cb.moveTo(0, 0);
        String options[] = { "A", "B", "C" };
        PdfFormField field = PdfFormField.createCombo(writer, true, options, 0);
        field.setWidget(new Rectangle(100, 700, 180, 720), PdfAnnotation.HIGHLIGHT_INVERT);
        field.setFieldName("ACombo");
        field.setValueAsString("B");
        writer.addAnnotation(field);

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

From source file:ChangingDocumentMarginPDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A5, 36, 72, 108, 180);
    try {/*from  w  w  w . ja v  a  2  s  .  c  om*/
        PdfWriter.getInstance(document, new FileOutputStream("ChangingDocumentMarginPDF.pdf"));
        document.open();

        Paragraph paragraph = new Paragraph();
        paragraph.setAlignment(Element.ALIGN_JUSTIFIED);
        for (int i = 0; i < 60; i++) {
            paragraph.add("www.java2s.com has demo for Java, JavaScript, PDF.");
        }
        document.add(paragraph);

        document.setMargins(180, 108, 72, 36);
        document.add(new Paragraph("Now we change the margins. You will see the effect on the next page."));

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

From source file:GettingDefaultCellPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//w  ww. j  ava2  s  . com
        PdfWriter.getInstance(document, new FileOutputStream("GettingDefaultCellPDF.pdf"));
        document.open();

        PdfPTable table = new PdfPTable(3);
        PdfPCell cell = new PdfPCell(new Paragraph("header with colspan 3"));
        cell.setColspan(3);
        table.addCell(cell);
        table.getDefaultCell().setGrayFill(0.8f);
        table.addCell("1.1");
        table.addCell("2.1");
        table.addCell("3.1");

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

From source file:HyphenationPDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A6);
    try {/* w w w. ja va 2  s .c  o  m*/
        PdfWriter.getInstance(document, new FileOutputStream("HyphenationPDF.pdf"));

        document.open();
        String text = "\u2014";
        Chunk ck = new Chunk(text);
        HyphenationAuto auto = new HyphenationAuto("en", "GB", 2, 2);
        ck.setHyphenation(auto);
        Paragraph p = new Paragraph(ck);
        p.setAlignment(Paragraph.ALIGN_JUSTIFIED);
        document.add(p);
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:StrokeClosePDF.java

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

        document.open();
        PdfContentByte cb = writer.getDirectContent();

        cb.setLineWidth(10f);
        cb.setRGBColorStrokeF(0f, 255f, 0f);
        cb.moveTo(100, 700);
        cb.lineTo(200, 800);
        cb.lineTo(200f, 250f);
        cb.lineTo(400f, 150f);

        cb.closePathFillStroke();

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

From source file:TableCellWithFontPDF.java

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

        PdfPTable table = new PdfPTable(1);
        PdfPCell cell = new PdfPCell(new Phrase("phrase without font"));

        table.addCell(cell);
        table.addCell(new Phrase("A", FontFactory.getFont(FontFactory.HELVETICA, 8)));
        table.addCell("no font");

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

From source file:ColumnAlignmentPDF.java

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

        PdfContentByte cb = writer.getDirectContent();

        ColumnText ct = new ColumnText(cb);
        ct.setSimpleColumn(60, 300, 100, 300 + 28 * 15, 15, Element.ALIGN_CENTER);
        ct.addText(new Phrase("col \n"));
        ct.addText(new Phrase("cool \n"));
        ct.addText(new Phrase("coool\n"));
        ct.addText(new Phrase("cooool\n"));
        ct.go();

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

From source file:LayerShapeOnTextPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from   ww  w.  j  a  v a 2s .c  om
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("LayerShapeOnTextPDF.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);

        PdfContentByte cb = writer.getDirectContent();
        cb.setRGBColorFill(0xFF, 0xFF, 0xFF);
        cb.circle(250.0f, 500.0f, 50.0f);
        cb.fill();

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

From source file:TextRightLeftPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from w  ww  .jav a2 s.co  m*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TextRightLeftPDF.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();

        cb.beginText();

        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
        cb.setFontAndSize(bf, 12);

        cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, " Right", 250, 350, 0);
        cb.showTextAligned(PdfContentByte.ALIGN_LEFT, " Left", 250, 300, 0);

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