  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | JSP - A mailing list about Java Server Pages specification and reference | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Fail to load document (Solved) | Fail to load document (Solved) 2006-08-18 - By Md Sagri
Back Hi , this problem is solved using the code below: response.reset(); response.setHeader("Expires", "0") response.setHeader("Cache -Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "no-cache"); response.setHeader("Content-disposition", "attachment; filename=\"" + issueDate + ".pdf\""); response.setContentType("application/pdf"); Document document = new Document(PageSize.A4); OutputStream out = response.getOutputStream(); PdfWriter.getInstance(document, out); document.open(); /*8 * data holds blob retrieved */ byte data[] = null; data = imageData Image image2 = Image.getInstance(data); document.add(image2); document.newPage(); } document.close(); But this time I have a new problem. once I open the document every thing is as expected. When I go down the pages and return back. Every thing is erased. If I reopen this document the same thing is happenning. Can any one please tell me if it is my Documents problem. I am usin Evince Document Viewer that comes with linux. Md Sagri <md_sagri@(protected)> wrote: Hi all, I am repeatedly getting this error when I open a pdf file created by my server. UNABLE TO OPEN DOCUMENT Fail to load document (error:3) 'file;///location/myfile.pdf' My code to generate this file is this: ByteArrayOutputStream baos = new ByteArrayOutputStream(); Document document = new Document(PageSize.A4); PdfWriter.getInstance(document, baos); document.open(); document.add(new Paragraph(new Date().toString())); for(int j=0; j<100;j++){ document.add(new Paragraph("sagri your pdf is working well")); document.add(Chunk.NEWLINE); } response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); response.setHeader("Contgent-disposition", "attachment; filename=\"" + issueDate + ".pdf\""); response.setContentType("application/pdf"); response.setContentLength(baos.size()); ServletOutputStream out = response.getOutputStream(); baos.writeTo(out); out.flush(); document.close(); ************************************************************************* Instead of printing a line i wanted to add a image using [[[[ byte[] imagedata = null; try { Blob image = page.getFile(); imagedata = image.getBytes(1, (int) image.length()); } catch (Exception e) { log.error("Exception in getting the file", e); return null; } return imagedata; ]]]] byte[] data = imagedata; Image image2 = Image.getInstance(200, 150, 3, 8, data); document.add(image2); when I execute this code the generated exception shows unknown source for image2. Exception:....................document.add(unknown source).......... ************************************************************************** what way can we add data to a pdf that can be downloadable .
-- ---- ---- ---- ---- ---- ----- Here's a new way to find what you're looking for - Yahoo! Answers Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it NOW-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642__ ____ __ ____ ____ ____ ____ ____ ____ ____ __ iText-questions mailing list iText-questions@(protected) https://lists.sourceforge.net/lists/listinfo/itext-questions
-- ---- ---- ---- ---- ---- ----- Here's a new way to find what you're looking for - Yahoo! Answers Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it NOW Hi ,<br> this problem is solved using the code below:<br> <br> response.reset() ;<br> response.setHeader("Expires", "0") response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");<br> response.setHeader("Pragma", "no-cache");<br> response.setHeader("Content-disposition", "attachment; filename=\""<br>   ; + issueDate + ".pdf\"");<br> <br> <br> response.setContentType("application/pdf");<br> <br> Document document = new Document(PageSize.A4); <br> <br> OutputStream out = response.getOutputStream();<br> PdfWriter.getInstance(document, out);<br> <br> document.open();<br> <br> /*8<br> * data holds blob retrieved <br> */<br> <br>   ; byte data[] = null;<br> <br>   ; data = imageData<br> Image image2 = Image.getInstance(data);<br> document.add(image2);<br> document.newPage();<br>   ; }<br> <br> <br>   ; document.close();<br>But this time I have a new problem. <br> <br> once I open the document every thing is as expected. When I go down the pages and return back. Every thing is erased.<br> <br> If I reopen this document the same thing is happenning.<br> Can any one please tell me if it is my Documents problem.<br> I am usin Evince Document Viewer that comes with linux.<br> <br><b ><i>Md Sagri <md_sagri@(protected)></i></b> wrote:<blockquote class= "replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> Hi all,<br> I am repeatedly getting this error when I open a pdf file created by my server.<br> <br> UNABLE TO OPEN DOCUMENT<br> Fail to load document (error:3) 'file;// /location/myfile.pdf'<br> <br> My code to generate this file is this:<br> ByteArrayOutputStream baos = new ByteArrayOutputStream();<br> Document document = new Document(PageSize.A4);<br> <br> PdfWriter.getInstance(document, baos);<br> document.open();<br> document.add(new Paragraph(new Date() .toString()));<br> for (int j=0; j<100;j++){<br> document.add(new Paragraph("sagri your pdf is working well"));<br> document.add(Chunk.NEWLINE); <br> }<br> response .setHeader("Expires", "0");<br> response.setHeader("Cache-Control", "must -revalidate, post-check=0, pre-check=0");<br> response.setHeader( "Pragma", "public");<br> response.setHeader("Contgent-disposition", "attachment; filename=\""<br>   ; + issueDate + ".pdf\"");<br> response.setContentType("application /pdf");<br> response.setContentLength(baos.size());<br> ServletOutputStream out = response.getOutputStream();<br> baos.writeTo(out);<br> out.flush();<br> <br> document.close();<br> ******** *****************************************************************<br> Instead of printing a line i wanted to add a image using<br> <br> [[[[ byte[] imagedata = null;<br> try {<br> Blob image = page.getFile();<br> imagedata = image.getBytes(1, (int) image .length());<br> } catch (Exception e) {<br> log.error("Exception in getting the file", e);<br> return null;<br> }<br> return imagedata; <br> ]]]]<br> <br> byte[] data = imagedata;<br> Image image2 = Image.getInstance(200, 150, 3, 8, data);<br> document.add(image2);<br> <br> when I execute this code the generated exception shows unknown source for image2.<br> <br> Exception:................... .document.add(unknown source)..........<br> ************************************ **************************************<br> what way can we add data to a pdf that can be downloadable .<br> <br> <div> </div><hr size="1"> Here's a new way to find what you're looking for - <a href="http://us.rd.yahoo .com/mail/in/yanswers/*http://in.answers.yahoo.com/">Yahoo! Answers</a> <br> Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. <a href= "http://in.rd.yahoo.com/mail/in/messengertagline/*http://in.messenger.yahoo.com" >Get it NOW</a>-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- -- -----<br>Using Tomcat but need to do more? Need to support web services, security?<br>Get stuff done quickly with pre -integrated technology to make your job easier<br>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo<br>http://sel.as-us.falkag .net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642__ ____ ____ ______ __ ____ ____ ____ ____ _____<br>iText-questions mailing list<br>iText-questions @(protected)<br>https://lists.sourceforge.net/lists/listinfo/itext -questions<br></blockquote><br><p> 
<hr size=1></hr> Here's a new way to find what you're looking for - <a href="http://us.rd.yahoo .com/mail/in/yanswers/*http://in.answers.yahoo.com/">Yahoo! Answers</a> <BR> Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. <a href= "http://in.rd.yahoo.com/mail/in/messengertagline/*http://in.messenger.yahoo.com" >Get it NOW</a> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 __ ____ ____ ____ ____ ____ ____ ____ ____ ____ iText-questions mailing list iText-questions@(protected) https://lists.sourceforge.net/lists/listinfo/itext-questions
|
|
 |