Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting byte array to PDF and display in JSP page

Tags:

java

html

jsp

I am doing a JSP site, where I need to display PDF files. I have byte array of PDF file by webservice and I need to display that byte array as PDF file in HTML. My question is how to covert that byte array as PDF and display that PDF in new tab.

like image 231
abhi Avatar asked Mar 23 '23 07:03

abhi


1 Answers

save these bytes on the disk by using output stream.

FileOutputStream fos = new FileOutputStream(new File(latest.pdf));

//create an object of BufferedOutputStream
bos = new BufferedOutputStream(fos);

byte[] pdfContent = //your bytes[]

bos.write(pdfContent);

Then send its link to client side to be opened from there. like http://myexamply.com/files/latest.pdf

like image 193
faisalbhagat Avatar answered Apr 01 '23 11:04

faisalbhagat