S
SG
I get Base64 encoded String for a PDF file. I convert that String to
character array. Then I decode it back to byte array. Now, I need to
use the byte array to display pdf.
I am using a Servlet to display byte array of PDF into IE browser.
Correct number of bytes are returned from existing PDF. Any help with
code will be appreciated. They key is, my input argument is byte array,
not the PDF itself.
I am using code below:
I am using code below.
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("application/pdf");
resp.setHeader("Expires", "0");
resp.setHeader("Cache-Control","must-revalidate, post-check=0,
pre-check=0");
resp.setHeader("Pragma", "public");
resp.setHeader("Pragma", "no-cache"); //HTTP 1.0
resp.setDateHeader("Expires", 0); //prevents caching at the proxy
server
resp.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
resp.setHeader("Cache-Control", "max-age=0");
resp.setHeader("Content-disposition", "inline; filename=stuff.pdf");
byte[] inputBytes = getBytesFromYourPDF(...);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
if(inputBytes !=null){
outputStream.write(inputBytes);
}
outputStream.flush();
}
Any help with code will be appreciated.
(e-mail address removed)
character array. Then I decode it back to byte array. Now, I need to
use the byte array to display pdf.
I am using a Servlet to display byte array of PDF into IE browser.
Correct number of bytes are returned from existing PDF. Any help with
code will be appreciated. They key is, my input argument is byte array,
not the PDF itself.
I am using code below:
I am using code below.
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("application/pdf");
resp.setHeader("Expires", "0");
resp.setHeader("Cache-Control","must-revalidate, post-check=0,
pre-check=0");
resp.setHeader("Pragma", "public");
resp.setHeader("Pragma", "no-cache"); //HTTP 1.0
resp.setDateHeader("Expires", 0); //prevents caching at the proxy
server
resp.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
resp.setHeader("Cache-Control", "max-age=0");
resp.setHeader("Content-disposition", "inline; filename=stuff.pdf");
byte[] inputBytes = getBytesFromYourPDF(...);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
if(inputBytes !=null){
outputStream.write(inputBytes);
}
outputStream.flush();
}
Any help with code will be appreciated.
(e-mail address removed)