List of usage examples for java.io FileOutputStream FileOutputStream
public FileOutputStream(FileDescriptor fdObj)
From source file:ImageTableCellPDF.java
public static void main(String[] args) { Document document = new Document(); try {//ww w .j av 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) throws Exception { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open();/*from ww w. j a va 2 s. co m*/ PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); table.setHeaderRows(1); PdfPCell h1 = new PdfPCell(new Paragraph("Header 1")); h1.setGrayFill(0.7f); table.addCell(h1); PdfPCell h2 = new PdfPCell(new Paragraph("Header 2")); h2.setGrayFill(0.7f); table.addCell(h2); PdfPCell cell; for (int row = 1; row <= 2000; row++) { document.add(table); table.deleteBodyRows(); table.setSkipFirstHeader(true); cell = new PdfPCell(new Paragraph(String.valueOf(row))); table.addCell(cell); cell = new PdfPCell(new Paragraph("Quick brown fox jumps over the lazy dog.")); table.addCell(cell); } document.add(table); document.close(); }
From source file:GettingDefaultCellPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w .ja v a2 s . c o m*/ PdfWriter.getInstance(document, new FileOutputStream("GettingDefaultCellPDF.pdf")); document.open(); PdfPTable table = new PdfPTable(3); PdfPCell cell = new PdfPCell(new Paragraph("header with colspan 3")); cell.setColspan(3); table.addCell(cell); table.getDefaultCell().setGrayFill(0.8f); table.addCell("1.1"); table.addCell("2.1"); table.addCell("3.1"); document.add(table); } 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(PageSize.A8.rotate()); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open();/*from w w w .j ava 2 s . co m*/ String text = "this is a test"; Paragraph paragraph = new Paragraph(text); paragraph.setAlignment(Element.ALIGN_JUSTIFIED); document.add(paragraph); document.newPage(); writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO); document.add(paragraph); document.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document.compress = false;//from ww w . j a v a 2s . co m Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.setColorStroke(new GrayColor(0.2f)); cb.setColorFill(new GrayColor(0.9f)); cb.moveTo(30, 700); cb.lineTo(130, 700); cb.lineTo(130, 800); cb.lineTo(30, 800); cb.stroke(); document.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document.compress = false;/*from w w w. ja v a 2 s . c o m*/ Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.setColorStroke(new GrayColor(0.2f)); cb.setColorFill(new GrayColor(0.9f)); cb.moveTo(250, 700); cb.lineTo(350, 700); cb.lineTo(350, 800); cb.lineTo(250, 800); cb.fill(); document.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document.compress = false;/*from w w w . j a v a 2 s .com*/ Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.setColorStroke(new GrayColor(0.2f)); cb.setColorFill(new GrayColor(0.9f)); cb.moveTo(470, 700); cb.lineTo(570, 700); cb.lineTo(570, 800); cb.lineTo(470, 800); cb.closePathFillStroke(); document.close(); }
From source file:LayerImageOnTextPDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w ww .j a v a 2s .c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("LayerImageOnTextPDF.pdf")); document.open(); Paragraph p = new Paragraph(); for (int i = 0; i < 100; i++) p.add(new Chunk("Text Text Text Text Text Text Text Text ")); document.add(p); Image img = Image.getInstance("logo.png"); img.setAbsolutePosition(100, 500); document.add(img); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document.compress = false;//from ww w . j ava 2s . c o m Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.circle(26.0f, 50.0f, 25.0f); cb.fill(); cb.saveState(); cb.setColorFill(Color.yellow); cb.circle(26.0f, 50.0f, 20.0f); cb.fill(); cb.saveState(); cb.setColorFill(Color.red); cb.circle(26.0f, 50.0f, 15.0f); cb.fill(); cb.restoreState(); cb.circle(26.0f, 50.0f, 10.0f); cb.fill(); cb.restoreState(); cb.circle(26.0f, 50.0f, 5.0f); cb.fill(); document.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document.compress = false;//from ww w . j a v a 2 s. c om Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.setColorStroke(new GrayColor(0.2f)); cb.setColorFill(new GrayColor(0.9f)); cb.moveTo(360, 700); cb.lineTo(460, 700); cb.lineTo(460, 800); cb.lineTo(360, 800); cb.fillStroke(); document.close(); }