I have a function called decode(sPDFImage);
Here is part of the function:
<%! public static char[] decode(String text) {
return decode(text.toCharArray());
}
%>
The sPDFImage is the actual pdf base64 which needs to be converted to binary.
Basically, I have the pdf displaying properly in the browser but now I need to write the PDF to a file. I have the code doing this, but it won't open because it is not properly decoded.
This call:
out.print(decode(sPDFImage));
out.flush(); //added flush to ensure buffer is flushed for subsquent requests
out.close();
This works when it opens in the browser but I need to write it to a file then open it.
Here is my code which I am using:
DataOutputStream output_stream;
output_stream = new DataOutputStream(new FileOutputStream("c:\\" + sSessionID + ".pdf"));
char[] ray = new char[decode(sPDFImage).length];
int x = 0;
ray = decode(sPDFImage); //put the return array into ray[]
for(x = 0; x < ray.length; ++x){
System.out.print(ray[x]);
output_stream.writeUTF(ray[x]);
}
output_stream.close();
My machine starts beeping when I run this code
I do get stuff in the file but it is garbage, I need what is displayed in the browser as a PDF.
Anyways is there another way I can get the char array written to a pdf file that I can open?
Thanks Ray
[ December 03, 2002: Message edited by: Ray Smilgius ]
[ December 04, 2002: Message edited by: Ray Smilgius ]