Java Mailing List Archive

http://www.junlu.com/

Google
Google
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
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
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> &nbsp;&nbsp;&nbsp; UNABLE TO OPEN DOCUMENT<br> &nbsp;
&nbsp;&nbsp; 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> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; PdfWriter.getInstance(document, baos
);<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; document.open();<br> document.add
(new Paragraph(new Date().toString()));<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp
; &nbsp;&nbsp;&nbsp; for(int j=0; j&lt;100;j++){<br> &nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; document.add(new Paragraph("sagri your pdf is
working well"));<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
document.add(Chunk.NEWLINE);<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp; }<br>
response.setHeader("Expires", "0");<br> response.setHeader("Cache-Control",
"must-revalidate, post-check=0,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pre-check=0");<br> response.setHeader
("Pragma", "public");<br> response.setHeader("Contgent-disposition", "attachment
; filename=\""<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; + issueDate + ".pdf\"");<br> response
.setContentType("application/pdf");<br> response.setContentLength(baos.size());
<br> ServletOutputStream out = response.getOutputStream();<br> &nbsp;&nbsp;&nbsp
; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; baos.writeTo(out);<br> &nbsp;&nbsp;&nbsp
; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; out.flush();<br> &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
document.close();<br> *********************************************************
****************<br> &nbsp;&nbsp;&nbsp;
Instead of printing a line i wanted to add a image using<br> <br> [[[[ &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; byte[] imagedata =
null;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp; try {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blob
image = page.getFile();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; imagedata =
image.getBytes(1, (int) image.length());<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch (Exception
e) {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; log.error("Exception in getting
the file", e);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return null;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return imagedata;&nbsp;&nbsp;
<br> ]]]]<br> <br> &nbsp;byte[] data = imagedata;<br> Image image2 = Image
.getInstance(200, 150, 3, 8, data);<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; 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> &nbsp;what way can we add
data to a pdf that can be downloadable .<br> &nbsp;<br> <p>&#32;
 

 
    <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

©2008 junlu.com - Jax Systems, LLC, U.S.A.