Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i hava a 2d byte array of pdf file coming from web service. i need to convert that into pdf in my console application using. can anyone suggest something how to achieve that. Thanks in advance.

Java
byte[][] bytes=new byte[s.length][];
	        for (int i=0; i<s.length; i++) {
	            bytes[i]=org.apache.commons.codec.binary.Base64.decodeBase64(s[i].getBytes());}
Posted
Comments
Thomas Daniels 10-Jan-16 8:03am    
What exactly does this byte array contain?
Kornfeld Eliyahu Peter 10-Jan-16 8:10am    
If I understood correctly, all you have to do is to store the byte array into a file with pdf extension...
kunal_89 10-Jan-16 8:29am    
It has some stuff like this:
%PDF-1.5
%âãÏÓ
2 0 obj
<</Length 64/Filter/FlateDecode>>stream
binary stuff
endstream
endobj
4 0 obj
endobj
1 0 obj
Richard MacCutchan 10-Jan-16 8:36am    
Just do what Peter suggested above.
kunal_89 10-Jan-16 8:39am    
ok Richard and Peter.. I will try that. Thanks for your reply :)

1 solution

If your bytes array contains only characters then you can go with FileWriter. If it isn't then OutputStream is the way to go.
C#
OutputStream out = new FileOutputStream("out.pdf");
out.write(bArray);
out.close();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900