List of usage examples for java.lang Exception getMessage
public String getMessage()
From source file:StrokeColorPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w ww . ja v a2 s . c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("StrokeColorPDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.setLineWidth(10f); cb.setRGBColorStrokeF(0f, 255f, 0f); cb.moveTo(100, 700); cb.lineTo(200, 800); cb.stroke(); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:ParagraphsPDF.java
public static void main(String[] args) { Document document = new Document(); try {//w ww . ja v a 2s . c o m PdfWriter.getInstance(document, new FileOutputStream("ParagraphsPDF.pdf")); document.open(); Paragraph p1 = new Paragraph( new Chunk("This is my first paragraph. ", FontFactory.getFont(FontFactory.HELVETICA, 10))); p1.add("The default leading is 1.5 times the fontsize. "); p1.add(new Chunk("new chunks ")); p1.add(new Phrase("new phrases. ")); document.add(p1); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:SettingBackgroundSizePDF.java
public static void main(String[] args) { Document document = new Document(); try {//w w w. jav a2 s . c o m PdfWriter.getInstance(document, new FileOutputStream("SettingBackgroundSizePDF.pdf")); document.open(); Chunk c = new Chunk("background chunk"); c.setBackground(new Color(0xFF, 0x00, 0x00), 5f, 30f, -10f, 0f); Paragraph p = new Paragraph("The following chunk is "); p.add(c); document.add(p); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:NewPagePageEmptyPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from ww w. ja v a2 s . c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("NewPagePageEmptyPDF.pdf")); document.open(); document.add(new Paragraph("A")); document.newPage(); document.add(new Paragraph("B")); document.newPage(); document.add(Chunk.NEWLINE); document.newPage(); document.newPage(); document.add(new Paragraph("C")); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:ImageRotatingPDF.java
public static void main(String[] args) { Document document = new Document(); try {//from ww w . jav a2s.c o m PdfWriter.getInstance(document, new FileOutputStream("ImageRotatingPDF.pdf")); document.open(); Image jpg = Image.getInstance("logo.png"); jpg.setAlignment(Image.MIDDLE); jpg.setRotation((float) Math.PI / 6); document.add(new Paragraph("rotate 30 degrees")); document.add(jpg); document.newPage(); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:FillCirclesPDF.java
public static void main(String[] args) { Document document = new Document(); try {/* w w w . j a va2s . c om*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("FillCirclesPDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.setRGBColorFill(0xFF, 0x00, 0x00); cb.circle(250.0f, 500.0f, 200.0f); cb.circle(250.0f, 500.0f, 150.0f); cb.circle(350.0f, 300.0f, 150.0f); cb.fillStroke(); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:PhraseWithLeadingLinePDF.java
public static void main(String[] args) { Document document = new Document(); try {/*w ww. j a va 2 s . c o m*/ PdfWriter.getInstance(document, new FileOutputStream("PhraseWithLeadingLinePDF.pdf")); document.open(); Phrase phrase0 = new Phrase(); Phrase phrase1 = new Phrase("this is a phrase\n"); Phrase phrase2 = new Phrase(24, "this is a phrase with leading 24. Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text \n"); document.add(phrase0); document.add(phrase1); document.add(phrase2); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:DrawRectanglePDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w.j a v a 2 s . c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("DrawRectanglePDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate template = cb.createTemplate(500, 200); template.setLineWidth(2f); template.rectangle(2.5f, 2.5f, 495f, 95f); template.stroke(); template.setLineWidth(12f); cb.addTemplate(template, 0, 1, -1, 0, 500, 200); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:WidthHeightPDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w w w .j a v a 2 s .c om PdfWriter.getInstance(document, new FileOutputStream("WidthHeightPDF.pdf")); document.open(); BaseFont bfComic = BaseFont.createFont("c:\\windows\\fonts\\arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); document.add(new Paragraph("width: " + bfComic.getWidthPoint("a", 12))); document.add(new Paragraph("ascent: " + bfComic.getAscentPoint("A", 12))); document.add(new Paragraph("descent: " + bfComic.getDescentPoint("aaa", 12))); document.add(new Paragraph( "height: " + (bfComic.getAscentPoint("AAA", 12) - bfComic.getDescentPoint("AAA", 12)))); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:GreekListsPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from ww w .j a v a 2s . c o m*/ PdfWriter.getInstance(document, new FileOutputStream("GreekListsPDF.pdf")); document.open(); GreekList greek = new GreekList(15); greek.setGreekLower(true); greek.add(new ListItem("first item")); greek.add(new ListItem("second item")); for (int i = 3; i < 20; i++) { greek.add(i + "th item"); } document.add(greek); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }