List of usage examples for java.lang Exception getMessage
public String getMessage()
From source file:MeasurementsPDF.java
public static void main(String[] args) { Rectangle pageSize = new Rectangle(720, 720); /*/*from www.j a v a 2 s. com*/ * The size of this page is 720x720 points. 720pt / 72 points per inch = 10 inch. * The size of this page is 10x10 inch." (25.4 cm by 25.4 cm) since * 10 inch x 2.54 = 25.4 cm" */ Document document = new Document(pageSize, 36, 18, 72, 72); /* The left border is 36pt or 0.5 inch or 1.27 cm" right border is 18pt or 0.25 inch or 0.63 cm." top border is 72pt or 1 inch or 2.54 cm. bottom border 72pt or 1 inch or 2.54 cm. */ try { PdfWriter.getInstance(document, new FileOutputStream("MeasurementsPDF.pdf")); document.open(); document.add(new Paragraph("Measurements")); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:ImageAlignmentPDF.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.getInstance(document, new FileOutputStream("ImageAlignmentPDF.pdf")); document.open(); Image imageRight = Image.getInstance("logo.png"); imageRight.setAlignment(Image.RIGHT); Image imageCenter = Image.getInstance("logo.png"); imageCenter.setAlignment(Image.MIDDLE); Image imageLeft = Image.getInstance("logo.png"); imageLeft.setAlignment(Image.LEFT); document.add(imageRight); document.add(imageCenter); document.add(imageLeft); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:OutlineActionsJavaScriptCodePDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w .j av a 2 s . c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("OutlineActionsJavaScriptCodePDF.pdf")); writer.setViewerPreferences(PdfWriter.PageModeUseOutlines); document.open(); document.add(new Paragraph("Outline action example")); PdfContentByte cb = writer.getDirectContent(); PdfOutline root = cb.getRootOutline(); PdfOutline links = new PdfOutline(root, new PdfAction("http://www.java2s.com"), "Useful links"); PdfOutline other = new PdfOutline(root, new PdfDestination(PdfDestination.FIT), "other actions", false); other.setStyle(Font.ITALIC); new PdfOutline(other, PdfAction.javaScript("app.alert('Hello');\r", writer), "Say Hello"); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:TransformationsPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4); try {//from w ww . ja va2 s .c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TransformationsPDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate template = cb.createTemplate(120, 120); template.moveTo(30, 10); template.lineTo(90, 10); template.lineTo(10, 80); template.lineTo(30, 80); template.closePath(); template.stroke(); cb.addTemplate(template, 0, 0); cb.addTemplate(template, 0, 1, -1, 0, 200, 600); cb.addTemplate(template, .5f, 0, 0, .5f, 100, 400); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:ImageTableCellPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w. j a v a2s.c o m*/ PdfWriter.getInstance(document, new FileOutputStream("ImageTableCellPDF.pdf")); document.open(); Image image = Image.getInstance("logo.png"); PdfPTable table = new PdfPTable(2); table.addCell("cell"); table.addCell(image); table.addCell("cell"); table.addCell(new PdfPCell(image, true)); table.addCell("This three"); table.addCell(new PdfPCell(image, false)); document.add(table); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:MainClass.java
public static void main(String[] args) { try {// ww w . jav a 2s. co m String className = "oracle.jdbc.driver.OracleDriver"; Class driverObject = Class.forName(className); System.out.println("driverObject=" + driverObject); System.out.println("your installation of JDBC Driver OK."); } catch (Exception e) { System.out.println("Failed: JDBC Driver Error: " + e.getMessage()); } }
From source file:DrawTextWithRGBFillPDF.java
public static void main(String[] args) { Document document = new Document(); try {/* ww w .ja v a 2 s. c om*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("DrawTextWithRGBFillPDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate template = cb.createTemplate(500, 200); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); template.beginText(); template.setFontAndSize(bf, 180); template.setRGBColorFill(0xFF, 0x00, 0x00); template.showTextAligned(PdfContentByte.ALIGN_LEFT, "PDF", 125f, 35f, 0f); template.resetRGBColorFill(); template.endText(); cb.addTemplate(template, 0, 1, -1, 0, 500, 200); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:PdfContentByteColor.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w.j a v a 2 s . co m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("PdfContentByteColor.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", 50, 70, 0); cb.endText(); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:TemplatesDrawPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*w ww . j av a 2s. c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TemplatesDrawPDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate template = cb.createTemplate(500, 200); template.moveTo(0, 200); template.lineTo(500, 0); template.stroke(); template.circle(250f, 100f, 80f); template.stroke(); cb.addTemplate(template, 0, 0); document.newPage(); cb.addTemplate(template, 2, 0, 0, 2, -200, 400); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:RawDataFromImageFileAndManipulationPDF.java
public static void main(String[] args) { Document document = new Document(); try {/* w w w. ja va 2 s. com*/ PdfWriter.getInstance(document, new FileOutputStream("RawDataFromImageFileAndManipulationPDF.pdf")); document.open(); RandomAccessFile rf = new RandomAccessFile("logo.png", "r"); int size = (int) rf.length(); byte imext[] = new byte[size]; rf.readFully(imext); rf.close(); for (int i = 0; i < imext.length; i++) { imext[i] = (byte) (imext[i] + 3); } Image img1 = Image.getInstance(100, 100, 3, 8, imext); img1.setAbsolutePosition(200, 200); document.add(img1); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }