Reputation: 723
In my application, I want show a printable PDF acrobat file with in the browser or outside the browser other than saving. In Firefox by default it will ask for save or open, I don't need that dialogue. I want to show that file preferably outside the browser. Can you please suggest me.
Thanks,
Vara Kumar.PJD
Upvotes: 2
Views: 2939
Reputation: 3783
You can do like some thing like this.
response.setContentType("application/pdf");
InputStream in = new FileInputStream("answerconnect.pdf");
OutputStream out = response.getOutputStream();
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
Upvotes: 0
Reputation: 56
I don't think this is something you can control from your app, i think this is the matter of environment/browser/plugins that users are using... but zou can open new window for your pdf by javascript like this link
Upvotes: 1
Reputation: 1075467
You can suggest to the browser that it should show the PDF in a window rather than offering to download it via the Content-Disposition
header:
response.addHeader("Content-Disposition", "inline");
The "inline" value suggests that the content be rendered inline (as opposed to the "attachment" value suggesting the browser offer to download it).
Once you've made the suggestion to the browser, the browser may or may not accept your suggestion, depending on its implementation and possibly its user preferences.
Upvotes: 5