Code example for PrintStream

Methods: close, flush, println

0
 
public class TestPSFontEmbedder { 
    protected PrintStream os;
 
    public void openFile() throws IOException { 
        this.os = new PrintStream(new FileOutputStream("FontEmbedderPSTest.ps"));
    } 
 
    public void writeFont() throws IOException { 
 
        CharTable table = Lookup.getInstance().getTable("STDLatin");
        // System.out.println(table); 
        AffineTransform aff = new AffineTransform(1, 0, 0, -1, 0, 0);
 
        FontRenderContext context = new FontRenderContext(aff, false, false);
        // System.out.println(context); 
        // Font f = new Font("Lucida Sans Unicode", Font.PLAIN, 1000); 
        Font f = new Font("Arial", Font.PLAIN, 1000);
        // System.out.println(f); 
        FontIncluder fe = new PSFontEmbedder(context, os);
 
        // System.out.println(fe.getUnicode()); 
        // System.out.println("start include font"); 
        // ??????? fe.includeFont(f, table, "STDLatin"); 
        fe.includeFont(f, table, "ExampleFont");
        // System.out.println(fe.getNODefinedChars()); 
    } 
 
    public void closeFile() throws IOException { 
        // ??????? os.println("\t/ExampleFont exch definefont pop"); 
        os.println("/ExampleFont findfont 26 scalefont setfont");
        os.println("66 72 moveto");
        os.println("(ABC abc) show");
        os.flush();
        os.close();
    } 
 
    public static void main(String[] args) throws IOException {
        TestPSFontEmbedder test = new TestPSFontEmbedder();
        test.openFile();