  | 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 (error:3) | Fail to load document (error:3) 2006-08-17 - By Md Sagri
Back 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 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> <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
|
|
 |