List of usage examples for java.lang Exception getMessage
public String getMessage()
From source file:TextFieldsPDF.java
License:asdf
public static void main(String[] args) { Document document = new Document(PageSize.A4.rotate()); try {//from www.j av a 2 s .co m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TextFieldsPDF.pdf")); document.open(); TextField tf = new TextField(writer, new Rectangle(100, 300, 100 + 100, 300 + 50), "asdf"); tf.setBackgroundColor(Color.WHITE); tf.setBorderColor(Color.BLACK); tf.setBorderWidth(1); tf.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED); tf.setText("text..."); tf.setAlignment(Element.ALIGN_CENTER); tf.setOptions(TextField.MULTILINE | TextField.REQUIRED); tf.setRotation(90); PdfFormField field = tf.getTextField(); writer.addAnnotation(field); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:PdfPageEventHelperDemo.java
public static void main(String[] args) { Document document = new Document(); try {//from w ww.j av a 2s. com PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("PdfPageEventHelperDemo.pdf")); writer.setPageEvent(new PdfPageEventHelperDemo()); document.open(); Paragraph p = new Paragraph("Generic page event"); document.add(p); Chunk box = new Chunk("text"); box.setGenericTag("text"); p.add(box); document.add(p); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:PdfEvents.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 80, 50, 30, 65); try {/*from w ww . j ava 2 s. c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("PdfEvents.pdf")); document.open(); writer.setPageEvent(new MyPageEvents()); document.newPage(); document.add(new Paragraph("Text")); document.close(); } catch (Exception e) { System.err.println(e.getMessage()); } }
From source file:G2DDrawStringPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w . ja va 2 s . c om*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("G2DDrawStringPDF.pdf")); document.open(); DefaultFontMapper mapper = new DefaultFontMapper(); FontFactory.registerDirectories(); mapper.insertDirectory("c:\\windows\\fonts"); int w = 150; int h = 150; PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(w, h); Graphics2D g2 = tp.createGraphics(w, h, mapper); g2.drawString("text", 20, 20); g2.dispose(); cb.addTemplate(tp, 50, 400); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:SpecificCellWithDifferentWidthPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from ww w . j a v a 2s.co m*/ PdfWriter.getInstance(document, new FileOutputStream("SpecificCellWithDifferentWidthPDF.pdf")); document.open(); Table aTable; aTable = new Table(4, 4); // 4 rows, 4 columns aTable.setWidths(new float[] { 2f, 1f, 1f, 1f }); aTable.setAlignment(Element.ALIGN_RIGHT); aTable.addCell("2.2", new Point(2, 2)); aTable.addCell("3.3", new Point(3, 3)); aTable.addCell("2.1", new Point(2, 1)); aTable.addCell("1.3", new Point(1, 3)); document.add(aTable); aTable.setConvert2pdfptable(true); document.add(aTable); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:ListsWithDifferentFontPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w ww. jav a2 s . c o m*/ PdfWriter.getInstance(document, new FileOutputStream("ListsWithDifferentFontPDF.pdf")); document.open(); document.add(new Paragraph("a paragraph")); ListItem listItem; List list = new List(true, 15); listItem = new ListItem("List item 1", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12)); listItem.add(new Chunk("appended list item text", FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.ITALIC))); list.add(listItem); listItem = new ListItem("List item 2", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12)); listItem.add(new Chunk("with different font and font size", FontFactory.getFont(FontFactory.COURIER_BOLD, 15, Font.ITALIC))); list.add(listItem); document.add(list); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:Main.java
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice screen = ge.getDefaultScreenDevice(); if (!screen.isFullScreenSupported()) { System.out.println("Full screen mode not supported"); System.exit(1);//from www. j a v a 2 s . c o m } try { BufferedImage loadedpic = ImageIO.read(new File("your.jpg")); screen.setFullScreenWindow(new Main(loadedpic)); } catch (Exception e) { System.err.println(e.getMessage()); } }
From source file:MainClass.java
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice screen = ge.getDefaultScreenDevice(); if (!screen.isFullScreenSupported()) { System.out.println("Full screen mode not supported"); System.exit(1);//from w ww .j a v a 2 s. c o m } try { BufferedImage loadedpic = ImageIO.read(new File("your.jpg")); screen.setFullScreenWindow(new MainClass(loadedpic)); } catch (Exception e) { System.err.println(e.getMessage()); } }
From source file:PaddingBordersPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w .j av a 2 s . co m*/ PdfWriter.getInstance(document, new FileOutputStream("PaddingBordersPDF.pdf")); document.open(); Table table = new Table(2); table.setBorderWidth(1); table.setPadding(10); Cell cell = new Cell("header"); cell.setHeader(true); cell.setColspan(2); table.addCell(cell); table.addCell("1.1"); table.addCell("2.1"); table.addCell("3.1"); table.addCell("1.2"); table.addCell("2.2"); table.addCell("3.2"); document.add(table); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:Main.java
public static void main(String args[]) { try {//from w w w. j av a2 s.c o m MongoClient mongoClient = new MongoClient("localhost", 27017); // Now connect to your databases DB db = mongoClient.getDB("test"); System.out.println("Connect to database successfully"); boolean auth = db.authenticate("myUserName", "myPassword".toCharArray()); System.out.println("Authentication: " + auth); DBCollection coll = db.createCollection("mycol", null); System.out.println("Collection created successfully"); } catch (Exception e) { System.err.println(e.getClass().getName() + ": " + e.getMessage()); } }