Example usage for java.io FileOutputStream FileOutputStream

List of usage examples for java.io FileOutputStream FileOutputStream

Introduction

In this page you can find the example usage for java.io FileOutputStream FileOutputStream.

Prototype

public FileOutputStream(FileDescriptor fdObj) 

Source Link

Document

Creates a file output stream to write to the specified file descriptor, which represents an existing connection to an actual file in the file system.

Usage

From source file:ZapfDingbatsLists.java

public static void main(String[] args) {
    Document document = new Document();
    try {// w w  w .  jav a 2 s  .c  o m
        PdfWriter.getInstance(document, new FileOutputStream("ZapfDingbatsLists.pdf"));
        document.open();

        ZapfDingbatsList z = new ZapfDingbatsList(42, 15);
        z.add(new ListItem("first item"));
        z.add(new ListItem("second item"));
        for (int i = 3; i < 20; i++) {
            z.add(i + "th item");
        }
        document.add(z);
        document.newPage();

    } 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("2.pdf"));
    document.open();//from  w  w  w  .j  a v a 2 s  .c om
    RomanList romanlist = new RomanList(20);
    romanlist.setRomanLower(true);
    romanlist.add(new ListItem("A"));
    romanlist.add(new ListItem("B"));
    document.add(romanlist);
    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  .  jav  a2 s.c  o m
    BaseFont bf = BaseFont.createFont("esl_gothic_unicode.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
    Font font = new Font(bf, 12);
    System.err.println(bf.getClass().getName());
    document.add(new Paragraph("this is a test.", font));
    document.add(new Paragraph("\ue70a\ue70a\ue70a\ue70a\ue70a\ue70a ", font));
    document.close();
}

From source file:ImagesUNDERLYINGPDF.java

public static void main(java.lang.String[] args) {
    Document document = new Document();
    try {/*w w  w.  j av a2 s.c  om*/
        PdfWriter.getInstance(document, new FileOutputStream("ImagesUNDERLYINGPDF.pdf"));
        document.open();

        Image imageRight = Image.getInstance("logo.png");
        imageRight.setAlignment(Image.UNDERLYING);

        for (int i = 0; i < 100; i++) {
            document.add(new Phrase("Text "));
        }
        document.add(imageRight);
        for (int i = 0; i < 100; i++) {
            document.add(new Phrase("Text "));
        }
    } 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;//www .j  a v  a2s . com
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream("HelloWorldOpen.pdf"));
    document.setPageSize(PageSize.LETTER.rotate());
    document.setMargins(36, 72, 108, 144);
    document.open();
    document.add(new Paragraph("Hello World"));
    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   www  .  j a  v a  2 s .c  o m
    BaseFont bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);
    System.err.println(bf.getClass().getName());
    Font font = new Font(bf, 12);
    document.add(new Paragraph("0123456789\nabcdefghijklmnopqrstuvwxyz\nABCDEFGHIJKLMNOPQRSTUVWXZ", font));
    document.close();
}

From source file:PaddingBordersPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {// w ww. ja v  a2 s .  c om
        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:ImagesDefaultWRAPPDF.java

public static void main(java.lang.String[] args) {
    Document document = new Document();
    try {//from   ww w.ja  v  a2  s .c  o m
        PdfWriter.getInstance(document, new FileOutputStream("ImagesDefaultWRAPPDF.pdf"));
        document.open();

        Image imageRight = Image.getInstance("logo.png");
        imageRight.setAlignment(Image.LEFT);

        for (int i = 0; i < 100; i++) {
            document.add(new Phrase("Text "));
        }
        document.add(imageRight);
        for (int i = 0; i < 100; i++) {
            document.add(new Phrase("Text "));
        }
    } 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  w  ww .  ja  v  a 2s .  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.moveTo(72, 650);
    cb.lineTo(72, 600);
    cb.moveTo(144, 650);
    cb.lineTo(144, 600);
    cb.stroke();
    cb.restoreState();
    document.close();
}

From source file:ChunksFontBackgroundPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*w w  w. j  a v a  2  s.  c o  m*/
        PdfWriter.getInstance(document, new FileOutputStream("ChunksFontBackgroundPDF.pdf"));
        document.open();

        Chunk test = new Chunk("some text");
        float superscript = 8.0f;
        test.setTextRise(superscript);
        test.setBackground(new Color(0xFF, 0xDE, 0xAD));
        test.setAnchor("http://www.java2s.com");
        test.setAnchor(new URL("http://www.java2s.com"));
        document.add(test);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}