----- Original Message ----- 
From: "Patrick O. Thurman" <[EMAIL PROTECTED]>
To: "'Post all your questions about iText here'" 
<[email protected]>
Sent: Tuesday, October 31, 2006 4:55 PM
Subject: Re: [iText-questions] java.io.IOException when tring to read 
PDFtemplate file


> Maybe I was not clear.  I need to know why I am getting the IOException.

No idea. My solution is to do the iText operations in memory and then output 
it using the regular Java stream classes to isolate the problem. I also ask 
you if the code works in test but not in production why would this be iText 
fault?

Paulo

> The template PDF file exists and is in the right place and the OS security
> is correct.
>
>
> pat
>
>
>> You may produce your PdfReader from a byte array and output the result
>> to a ByteArrayOutputStream.
>
> Paulo
>
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On
>> Behalf Of Patrick O. Thurman
>> Sent: Tuesday, October 31, 2006 4:20 PM
>> To: [email protected]
>> Subject: [iText-questions] java.io.IOException when tring to
>> read PDFtemplate file
>>
>>
>> Good Morning all,
>>
>> I have a java class that reads a PDF template file and fills
>> in the input
>> fields:
>>
>>
>>
>> import com.lowagie.text.pdf.AcroFields;
>>
>> import com.lowagie.text.pdf.PdfReader;
>>
>> import com.lowagie.text.pdf.PdfStamper;
>>
>> import java.io.FileOutputStream;
>>
>> import java.sql.*;
>>
>> import java.text.SimpleDateFormat;
>>
>>
>>
>> /**
>>
>>  * Fill in a simple registration form.
>>
>>  */
>>
>> public class readTemplatePDF {
>>
>>     /**
>>
>>      * Reads a form and fills in the fields.
>>
>>      * @param args no arguments needed
>>
>>      */
>>
>>     public static void main(String[] args) {
>>
>>       readTemplatePDF d = new readTemplatePDF();
>>
>>       d.write(null);
>>
>>     }
>>
>>     public static String write(oracle.sql.ARRAY parms) {
>>
>>       String result = "0 -- Successfull";
>>
>>       String[] values = null;
>>
>>       int arraySize = 0;
>>
>>       SimpleDateFormat sdf = new
>> SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss.SS'
>> '");
>>
>>       try {
>>
>>         values = (String[])parms.getArray();
>>
>>         arraySize = parms.length();
>>
>>       }
>>
>>       catch (java.sql.SQLException ex) {
>>
>>         System.out.println(sdf.format(new java.util.Date()) + "
>> readTemplatePDF  >> " + ex.toString());
>>
>>       }
>>
>>       try {
>>
>>           // we create a reader to read the template PDF file
>>
>>
>>
>>          PdfReader reader = new PdfReader("PORA$DATA:[PORADATA.PDF]" +
>> values[0]);
>>
>>           int n = reader.getNumberOfPages();
>>
>>           PdfStamper stamp1 = new PdfStamper(reader, new
>> FileOutputStream("PORA$DATA:[PORADATA.PDF]" + values[1]));
>>
>>           AcroFields form1 = stamp1.getAcroFields();
>>
>>           int i = 2;
>>
>>           while (i < arraySize) {
>>
>>             form1.setField(values[i], values[i+1]);
>>
>>             i++;
>>
>>             i++;
>>
>>           }
>>
>>           stamp1.setFormFlattening(true);
>>
>>           stamp1.close();
>>
>>           result = "0 -- Successfull";
>>
>>       } catch (Exception ex) {
>>
>>           System.out.println(sdf.format(new java.util.Date()) + "
>> readTemplatePDF  >> " + ex.toString());
>>
>>           result = "9 -- Failed";
>>
>>       }
>>
>>       return result;
>>
>>     }
>>
>> }
>>
>>
>>
>> I receive a java.io.IOException when tring to create
>>
>>
>>
>> PdfReader reader = new PdfReader("PORA$DATA:[PORADATA.PDF]" +
>> values[0]);
>>
>>
>>
>>
>>
>>                 I have found in the code:
>>
>>
>>
>> public RandomAccessFileOrArray(String filename, boolean
>> forceRead) throws
>> IOException {
>>         File file = new File(filename);
>>         if (!file.canRead()) {
>>             if (filename.startsWith("file:/") ||
>> filename.startsWith("http://";) || filename.startsWith("https://";) ||
>> filename.startsWith("jar:")) {
>>                 InputStream is = new URL(filename).openStream();
>>                 try {
>>                     this.arrayIn = InputStreamToArray(is);
>>                     return;
>>                 }
>>                 finally {
>>                     try {is.close();}catch(IOException ioe){}
>>                 }
>>             }
>>             else {
>>                 InputStream is = BaseFont.getResourceStream(filename);
>>                 if (is == null)
>>                     throw new IOException(filename + " not
>> found as file or
>> resource.");
>>                 try {
>>                     this.arrayIn = InputStreamToArray(is);
>>                     return;
>>                 }
>>                 finally {
>>                     try {is.close();}catch(IOException ioe){}
>>                 }
>>             }
>>         }
>>
>>
>> Where I believe my exception is being generated.  What are
>> the reasons for
>> this exception other than the file not existing on the disk,
>> not in the
>> right place and not having the correct OS security?  Why is a
>> randomAccess
>> method being used to read a binary file?  I have this code running and
>> working in my test environment,  but cannot make it work in
>> production.  I
>> am a Oracle DBA and I am running this class as a stored
>> procedure within the
>> database.  I believe that this is a Oracle DB problem, but I
>> cannot find the
>> difference between test and prod to solve the problem.  I
>> believe this in
>> NOT a security/priviledge problem, but some thing different,
>> maybe file type
>> or..
>>
>>
>>
>>
>>
>>
>>
>> Pat,
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Patrick O. Thurman
>> Stephen F. Austin State University
>> Information Technology Services
>> Data Base Administrator
>> Phone:  (936) 468-1074
>> Fax:    (936) 468-1117
>>
>>
>>
>> --------------------------------------------------------------
>> -----------
>> 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
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/itext-questions
>>
>
>
> Aviso Legal:
> Esta mensagem i destinada exclusivamente ao destinatario. Pode conter
> informagco confidencial ou legalmente protegida. A incorrecta transmissco
> desta mensagem nco significa a perca de confidencialidade. Se esta 
> mensagem
> for recebida por engano, por favor envie-a de volta para o remetente e
> apague-a do seu sistema de imediato. I proibido a qualquer pessoa que nco 
> o
> destinatario de usar, revelar ou distribuir qualquer parte desta mensagem.
>
> Disclaimer:
> This message is destined exclusively to the intended receiver. It may
> contain confidential or legally protected information. The incorrect
> transmission of this message does not mean the loss of its 
> confidentiality.
> If this message is received by mistake, please send it back to the sender
> and delete it from your system immediately. It is forbidden to any person
> who is not the intended receiver to use, distribute or copy any part of 
> this
> message.
>
>
>
>
>
> -------------------------------------------------------------------------
> 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions 


-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to