List of usage examples for java.io FileOutputStream FileOutputStream
public FileOutputStream(FileDescriptor fdObj)
From source file:CreatingANewPagePDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w w w. j a v a2 s.co m PdfWriter.getInstance(document, new FileOutputStream("CreatingANewPagePDF.pdf")); document.open(); document.add(new Paragraph("First Page.")); document.setPageSize(PageSize.A3); document.newPage(); document.add(new Paragraph("This PageSize is A3.")); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException 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 www . ja va 2 s .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:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open();/*from w w w. ja v a 2 s . c o m*/ PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); PdfPCell cell = new PdfPCell( new Paragraph("Quick brown fox jumps over the lazy dog. Quick brown fox jumps over the lazy dog.")); cell = new PdfPCell(new Paragraph("Quick brown fox jumps over the lazy dog.")); table.addCell("padding 10"); cell.setPadding(10); table.addCell(cell); table.addCell("padding 0"); cell.setPadding(0); table.addCell(cell); document.add(table); document.close(); }
From source file:LocalDestinationPDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w w w.j av a2s. c om PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("LocalDestinationPDF.pdf")); document.open(); document.add(new Paragraph("Page 1")); document.newPage(); document.add(new Paragraph("Page 2")); PdfContentByte cb = writer.getDirectContent(); cb.localDestination("page2", new PdfDestination(PdfDestination.XYZ, -1, 10000, 0)); writer.setOpenAction("page2"); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:MainClass.java
License:asdf
public static void main(String[] args) throws Exception { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open();/*from w w w. ja va2 s . c om*/ Chunk space = new Chunk("asdf"); Paragraph paragraph = new Paragraph(); paragraph.add(space); document.add(paragraph); document.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(PageSize.A6); PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open();/*from ww w. j a v a 2 s. co m*/ document.setMarginMirroring(true); Chunk ck = new Chunk("this is a test"); HyphenationAuto auto = new HyphenationAuto("en", "GB", 2, 2); ck.setHyphenation(auto); Paragraph p = new Paragraph(ck); p.setAlignment(Paragraph.ALIGN_JUSTIFIED); document.add(p); document.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Junk obj1 = new Junk("A"); Junk obj2 = new Junk("B"); Junk obj3 = new Junk("V"); ObjectOutputStream objectOut = new ObjectOutputStream( new BufferedOutputStream(new FileOutputStream("C:/JunkObjects.bin"))); objectOut.writeObject(obj1); // Write object objectOut.writeObject(obj2); // Write object objectOut.writeObject(obj3); // Write object System.out.println("\n\nobj1:\n" + obj1 + "\n\nobj2:\n" + obj2 + "\n\nobj3:\n" + obj3); objectOut.close(); // Close the output stream }
From source file:BufferedCopy.java
public static void main(String[] args) throws Exception { BufferedInputStream bis = null; BufferedOutputStream bos = null; FileInputStream fis = new FileInputStream(args[0]); bis = new BufferedInputStream(fis); FileOutputStream fos = new FileOutputStream(args[1]); bos = new BufferedOutputStream(fos); int byte_; while ((byte_ = bis.read()) != -1) bos.write(byte_); }
From source file:AddingParagraphToAPagePDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w ww . j av a2s .com PdfWriter.getInstance(document, new FileOutputStream("AddingParagraphToAPagePDF.pdf")); document.open(); document.add(new Paragraph("First Page.")); document.setPageSize(PageSize.A3); document.newPage(); document.add(new Paragraph("This PageSize is A3.")); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:FontListPDF.java
public static void main(String[] args) { try {//from w w w . j a v a 2s. c o m Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("FontListPDF.pdf")); document.open(); Paragraph p = new Paragraph(); p.add(new Chunk("Font.TIMES_ROMAN", new Font(Font.TIMES_ROMAN, 12))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.ZAPFDINGBATS", new Font(Font.ZAPFDINGBATS, 12))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.SYMBOL", new Font(Font.SYMBOL, 12))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.BOLD|Font.SYMBOL", new Font(Font.BOLD | Font.SYMBOL, 12))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.STRIKETHRU", new Font(Font.STRIKETHRU, 12))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.STRIKETHRU|Font.BOLDITALIC", new Font(Font.STRIKETHRU | Font.BOLDITALIC, 12))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.HELVETICA", new Font(Font.HELVETICA, 12))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.HELVETICA", new Font(Font.HELVETICA, Font.DEFAULTSIZE))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.UNDERLINE", new Font(Font.UNDERLINE, Font.DEFAULTSIZE))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.COURIER ", new Font(Font.COURIER, Font.DEFAULTSIZE))); document.add(new Paragraph(p)); document.close(); } catch (Exception de) { de.printStackTrace(); } }