List of usage examples for java.io FileOutputStream FileOutputStream
public FileOutputStream(FileDescriptor fdObj)
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document.compress = false;/*from w ww. j av a2 s . c o m*/ Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.saveState(); cb.setLineWidth(8); cb.setLineJoin(PdfContentByte.LINE_JOIN_MITER); cb.setMiterLimit(2); cb.moveTo(75, 560); cb.lineTo(95, 590); cb.lineTo(115, 560); cb.stroke(); cb.restoreState(); cb.saveState(); cb.setLineWidth(8); cb.setLineJoin(PdfContentByte.LINE_JOIN_MITER); cb.setMiterLimit(2.1f); cb.moveTo(280, 500); cb.lineTo(295, 530); cb.lineTo(310, 500); cb.stroke(); cb.restoreState(); document.close(); }
From source file:EncapsulatedPostScript.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 50, 50, 50); try {/*from w w w. j a va 2 s .c om*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("EncapsulatedPostScript.pdf")); document.open(); Image img = Image.getInstance("yourpsFile.ps"); img.scalePercent(50); document.add(img); document.close(); } catch (Exception de) { de.printStackTrace(); } }
From source file:PDFListsAtoE.java
public static void main(String[] args) { Document document = new Document(); try {//from ww w . java2 s . c om 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:Main.java
public static void main(String[] args) throws Exception { FileOutputStream out = new FileOutputStream("test.txt"); ObjectOutputStream oout = new ObjectOutputStream(out); oout.writeObject(new Example()); oout.flush();/*from w w w . j ava2 s.c o m*/ oout.close(); ObjectInputStream ois = new ObjectInputStream(new FileInputStream("test.txt")); Example a = (Example) ois.readObject(); System.out.println(a.isDefault); System.out.println(a.string); ois.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Rectangle pageSize = new Rectangle(216f, 720f); Document document = new Document(pageSize); PdfWriter.getInstance(document, new FileOutputStream("HelloWorldNarrow.pdf")); document.open();/* ww w .j a v a2 s .c o m*/ document.add(new Paragraph("Hello World")); document.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { Properties prop = new Properties(); String s = "Chapter Count=200"; String s2 = "Tutorial Count=15"; // create a new input and output stream FileOutputStream fos = new FileOutputStream("properties.txt"); FileInputStream fis = new FileInputStream("properties.txt"); // write the first property in the output stream file fos.write(s.getBytes());//from ww w . j a v a 2s. c om // change the line between the two properties fos.write("\n".getBytes()); // write next property fos.write(s2.getBytes()); // load from input stream prop.load(fis); // print the properties list from System.out prop.list(System.out); }
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();/* www. ja v a2 s. com*/ Font font = new Font(Font.COURIER, 10, Font.BOLD); font.setColor(new Color(0xFF, 0xFF, 0xFF)); Chunk fox = new Chunk("this is a", font); fox.setBackground(new Color(0xa5, 0x2a, 0x2a)); Phrase p = new Phrase(fox); p.add(" test"); Chunk dog = new Chunk(" another test", new Font(Font.TIMES_ROMAN, 14, Font.ITALIC)); dog.setBackground(new Color(0xFF, 0x00, 0x00), 10, -30, 20, -10); p.add(dog); document.add(p); document.close(); }
From source file:DifferentTextBackgroundSuperscript.java
public static void main(String[] args) { Document document = new Document(); try {/*from www. ja v a 2s . co m*/ PdfWriter.getInstance(document, new FileOutputStream("DifferentTextBackgroundSuperscript.pdf")); document.open(); Chunk c = new Chunk("background"); c.setTextRise(8); c.setBackground(new Color(0xFF, 0x00, 0x00)); 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:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("ttf.pdf")); document.open();// w w w . ja v a 2 s.c o m BaseFont bf = BaseFont.createFont("c:/windows/fonts/ARBLI___.ttf", BaseFont.CP1252, BaseFont.EMBEDDED); Font font = new Font(bf, 12); System.err.println(bf.getClass().getName()); document.add(new Paragraph("This is font arial black italic (embedded)", font)); bf = BaseFont.createFont("c:/windows/fonts/ARBLI___.ttf", BaseFont.CP1252, BaseFont.NOT_EMBEDDED); font = new Font(bf, 12); document.add(new Paragraph("This is font arial black italic (not embedded)", font)); System.out.println("PostScript name:" + bf.getPostscriptFontName()); String[] encoding = bf.getCodePagesSupported(); for (int i = 0; i < encoding.length; i++) { System.out.println("encoding[" + i + "] = " + encoding[i]); } document.newPage(); String[][] name = bf.getFullFontName(); for (int i = 0; i < name.length; i++) { System.out.println(name[i][3] + " (" + name[i][0] + "; " + name[i][1] + "; " + name[i][2] + ")"); } document.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document.compress = false;//from w w w. j av a 2 s .com Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); Image eye = Image.getInstance("iTextLogo.gif"); eye.setAbsolutePosition(36, 780); cb.addImage(eye, true); cb.addImage(eye, 271, -50, -30, 550, 100, 100, true); document.close(); }