Your byte array must have exactly the same size as the input file, in this
case it must be 24895 bytes long not 32000.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: Joe Simoes [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, January 15, 2003 13:40
> To:   [EMAIL PROTECTED]
> Subject:      [iText-questions] PdfReader(byte[] pdfIn) constructor
> 
> Hi,
> 
> I have an application where I must combine multiple pdf files into a
> single pdf.
> The pdfs are retrieved from an Oracle table that stores the files as
> BLOBs.  I
> read each file into a byte[] which is then placed into a Vector.  I
> modified the
> "concat.java" program found at your site to handle the concatenation of
> the
> files by passing in the Vector of byte arrays.
> 
> I receive an error each time I try to use the PdfReader constructor with
> the
> byte[] parameter.  Below is a sample piece of code that throws the same
> exception.  This example is different from what I described above but it
> throws
> the same exception: "java.io.IOException: PDF startxref not found."  This
> is
> strange because the number of bytes read in exactly matches the number of
> bytes
> in the file.
> 
> Anyone have any ideas?
> 
> Thanks in advance,
> Joe
> 
> 
> package test.servlets;
> 
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.util.*;
> import com.lowagie.text.*;
> import com.lowagie.text.pdf.*;
> 
> public class TestPdfReader extends HttpServlet {
> 
> public void doGet(HttpServletRequest request, HttpServletResponse
> response) {
>       byte buf[] = new byte[32000];
>       int readLength = 0;
>       StringBuffer message = new StringBuffer();
> 
>       try {
>             // This file contains 24,845 bytes (not encrypted)
>             FileInputStream in = new
> FileInputStream("c:\\junk\\test.pdf");
> 
>             // The file is smaller than the buffer so I know I can read it
>             // in without looping through the FileInputStream
>             readLength = in.read(buf, 0, buf.length);
>             message.append("# of bytes read: " + readLength + "<BR>");
> 
>             // Can't get past this line
>             PdfReader reader = new PdfReader(buf);
> 
>             // If I get here then everything is ok
>             message.append("reached the end, no exceptions thrown");
>       }
>       catch (Exception e){
>             message.append(e.toString());
>       }
> 
>       try {
>             response.setContentType("text/html");
>             java.io.PrintWriter out = new
> java.io.PrintWriter(response.getOutputStream());
>             out.println(message);
>             out.flush();
>       } catch (Exception e){
>             log(e.toString());
>       }
> }
> }
> 
> 
> 
> -------------------------------------------------------
> This SF.NET email is sponsored by: Take your first step towards giving 
> your online business a competitive advantage. Test-drive a Thawte SSL 
> certificate - our easy online guide will show you how. Click here to get 
> started: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0027en
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions


-------------------------------------------------------
This SF.NET email is sponsored by: Take your first step towards giving 
your online business a competitive advantage. Test-drive a Thawte SSL 
certificate - our easy online guide will show you how. Click here to get 
started: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0027en
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to