¹¹ pdf.js °°Àº view¸¦ ¾²´Â ¹æ¹ýµµ ÀÖÁö¸¸
ÀÌ ¹æ¹ýÀÌ »ý°¢º¸´Ù ±ò²ûÇÏ´Ù..
½ºÅ©¸³Æ® ´Ü¿¡¼ window.open À¸·Î È£ÃâÇÏ°í
¼¹ö´Ü¿¡¼ ¾Æ·¡ Äڵ带 ÀÛ¼ºÇÏ¸é µÈ´Ù.
¹Ø¿¡ ¼Ò½º´Â ³ëÆ®Æеå++°°Àºµ¥ ºÙ¿©³Ö¾î¼ º¸¸é ÆíÇÏ´Ù~
FileInputStream fis = null;
BufferedOutputStream bos = null;
try {
String pdfFileName = "C:/upload/TEST.pdf";
File pdfFile = new File(pdfFileName);
//Ŭ¶óÀ̾ðÆ® ºê¶ó¿ìÁ®¿¡¼ ¹Ù·Î º¸´Â ¹æ¹ý(Çì´õ º¯°æ)
response.setContentType("application/pdf");
//¡Ú ÀÌ ±¸¹®ÀÌ ÀÖÀ¸¸é [´Ù¿î·Îµå], ÀÌ ±¸¹®ÀÌ ¾ø´Ù¸é ¹Ù·Î target ÁöÁ¤µÈ °÷¿¡ view ÇØÁÝ´Ï´Ù.
response.addHeader("Content-Disposition", "attachment; filename="+pdfFile.getName()+".pdf");
//ÆÄÀÏ ÀÐ°í ¾²´Â °Ç ÀϹÝÀûÀÎ Write¹æ½ÄÀ̶û µ¿ÀÏÇÕ´Ï´Ù. ´Ù¸¸ reponse Ãâ·Â ½ºÆ®¸² °´Ã¼¿¡ write.
fis = new FileInputStream(pdfFile);
int size = fis.available(); //ÁöÁ¤ ÆÄÀÏ¿¡¼ ÀÐÀ» ¼ö ÀÖ´Â ¹ÙÀÌÆ® ¼ö¸¦ ¹Ýȯ
byte[] buf = new byte[size]; //¹öÆÛ¼³Á¤
int readCount = fis.read(buf);
response.flushBuffer();
bos = new BufferedOutputStream(response.getOutputStream());
bos.write(buf, 0, readCount);
bos.flush();
} catch(Exception e) {
e.printStackTrace();
} finally {
try {
if (fis != null) fis.close(); //close´Â ²À! ¹Ýµå½Ã!
if (bos != null) bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
[Ãâó] [Java] Pdf ÆÄÀÏ ´Ù¿î·Îµå or ¹Ù·Îº¸¿©ÁÖ±â|
ÀÛ¼ºÀÚ onandme