Results 1 to 1 of 1
- 02-14-2008, 07:15 PM #1
Member
- Join Date
- Feb 2008
- Posts
- 1
- Rep Power
- 0
Problem creating a Post script file
Hi,
I have to create a Postscript for a project that I am working on. The file that I create can not be opened by any application. I would be grateful for any help that anyone can give.
Java Code:public class PostScriptTest { public static void main(String[] args) throws IOException { File file = File.createTempFile("test", ".ps"); OutputStream os = new FileOutputStream (file); os.write(createHeader().toString().getBytes()); os.close(); } private static String getTodaysDate() { Date now = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); return sdf.format(now); } private static StringBuffer createHeader() { StringBuffer sb = new StringBuffer(); sb.append("%!PS-Adobe-2.0 EPSF-2.0\n" + "%%Creator: Page @VERSION@\n" + "%%Title: Page \n" + "%%CreationDate: " + getTodaysDate() + "\n" + "%%Origin: 0 0\n" + "%%BoundingBox: " + 0 + " " + 0 + " " + "\n" + "%%EndComments\n" + "%%BeginProlog\n" + "100 dict begin\n" + "/wordbreak ( ) def\n" + "/linebreak (\\n) def\n" + "/doLine {\n" + "% <line> <width> <height> <x> <y> doLine <width> <height> <x> <y>\n" + "2 copy moveto 5 -1 roll\n" + "wordbreak\n" + "{\n" + " search {\n" + " dup stringwidth pop currentpoint pop add 7 index 6 index " + "add gt {\n" + " 6 3 roll 2 index sub 2 copy moveto 6 3 roll\n" + " } if\n" + " show wordbreak show\n" + " }{\n" + " dup stringwidth pop currentpoint pop add 5 index 4 index " + "add gt {\n" + " 3 1 roll 3 index sub 2 copy moveto 3 -1 roll\n" + " } if\n" + " show exit\n" + " } ifelse\n" + "} loop\n" + "2 index sub 2 copy moveto\n" + "} def\n" + "/BreakIntoLines{\n" + "% <width> <height> <x> <y> <text> BreakIntoLines\n" + "linebreak\n" + "{\n" + " search {\n" + " 7 3 roll doLine 6 -2 roll\n" + " }{\n" + " 5 1 roll doLine exit\n" + " } ifelse\n" + " } loop\n" + "pop pop pop pop\n" + "} def\n" + "/to (" + "14355120438" + ") def\n" + "show"/*+ "/to-adress (" + "Page" + ") def\n" + "/from (" + from + ") def\n" + "/todays-date (" + getTodaysDate() + ") def\n" + "/regarding (" + regarding + ") def\n" + "/comments (" + generateComments() + ") def\n"*/); sb.append("%%EndProlog\n"); return sb; } }
Similar Threads
-
Creating jar file
By Heather in forum Advanced JavaReplies: 4Last Post: 02-11-2009, 09:58 AM -
creating jar file
By po0oker in forum Advanced JavaReplies: 3Last Post: 04-04-2008, 07:49 PM -
Creating a File object in Servlet
By Java Tip in forum Java TipReplies: 0Last Post: 01-16-2008, 10:24 AM -
creating .ear file
By psn in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 01-06-2008, 05:01 AM -
File creating date/time
By bugger in forum New To JavaReplies: 1Last Post: 11-11-2007, 07:43 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks