Hi Paulo,
u give me great Help with my problems.
Finally i discover i produce a good PDF File with iText. I try to open it vi HTTP and
it open without problems.
Problems arise when i try to show in a browser (IE or NN) a ByteArrayOutputStream
containing the PDF File. the browser don't start the plug-in(this is what i need!!)
but ask me to open or save the file.
I try two different solution, but both give me same output.
Solution 1 code:
// pdfOutStream is PDF generated with iText lib
pdfOutStream = (ByteArrayOutputStream) pdfFiller.filler(pdfType, mappingProperties,
richiedente);
byte[] buf = pdfOutStream.toByteArray();
String content = new String("application/pdf".getBytes(),"8859_1");
response.setContentType(content);
response.setContentLength(buf.length);
response.getOutputStream().write(buf);
Solution 2 code:
// pdfOutStream is PDF generated with iText lib
pdfOutStream = (ByteArrayOutputStream) pdfFiller.filler(pdfType, mappingProperties,
richiedente);
String content = new String("application/pdf".getBytes(),"8859_1");
response.setContentType(content);
response.setContentLength(pdfOutStream.size());
ServletOutputStream out = response.getOutputStream();
pdfOutStream.writeTo(out);
out.flush();
Have any idea to solve this problem, or someone can help me?
Thanks
Claudio Cantonetti
> Da: "Paulo Soares" <[EMAIL PROTECTED]>
> Data: Tue, 13 Jan 2004 16:20:49 -0000
> A: <[EMAIL PROTECTED]>
> Oggetto: RE: [iText-questions] setting Encoding
>
> You are doing some byte translation somewhere. The iText output is bytes, there's no
> encoding in the process. Let's say you generated the PDF and have it in some OS/390
> directory. If you transfer this PDF via FTP (in binary mode) to a windows machine
> does it work? If you look at the PDF in the OS/390 with an hex editor what are the
> first 4 bytes?
>
> Best Regards,
> Paulo Soares
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]
> > Sent: Tuesday, January 13, 2004 16:13
> > To: Paulo Soares
> > Cc: [EMAIL PROTECTED]
> > Subject: RE: [iText-questions] setting Encoding
> >
> > The Output i show you is the generated pdf.
> > When i try to open it with Acrobat Reader it say "There was an error opening the
> > Docoument.File does not begin with '%PDF-'."
> > Do u intend this when u ask me if i opened it?
> >
> > Other informations are:
> >
> > - System.property.file.encoding is set to Cp1047
> > - Java classes are also setted to encoding Cp1047
> > I cannot change these settings.
> > - My reader is the generated PDF I start from.
> > - The fields in logger.info are display correctly, so i presume the reading
> > sequence should be ok.
> >
> > For Test i tried the code in a Windows machine with Tomcat and "obviusly" it works.
> > - There's any test can i do in reading or writing process?
> > U need more info?
> >
> > Thanks for your time
> >����Claudio
> >
> >
> > > Da: "Paulo Soares" <[EMAIL PROTECTED]>
> > > Data: Tue, 13 Jan 2004 15:53:36 -0000
> > > A: <[EMAIL PROTECTED]>,
> > <[EMAIL PROTECTED]>
> > > Oggetto: RE: [iText-questions] setting Encoding
> > >
> > > iText works without any problem in OS/390 and AS400. Did you try to open the
> > > generated pdf?
> > >
> > > Best Regards,
> > > Paulo Soares
> > >
> > > > -----Original Message-----
> > > > From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED] On Behalf Of [EMAIL
> > > > PROTECTED]
> > > > Sent: Tuesday, January 13, 2004 15:18
> > > > To: [EMAIL PROTECTED]
> > > > Subject: [iText-questions] setting Encoding
> > > >
> > > > My problem is different from Ujjwala Kadam(UTF support).
> > > >
> > > > I'm using iText in an OS/390 machine with WebSphere 4.01.
> > > >
> > > > When i try to generate an output from a PDF File, this is the result i have in
> > > > the outputStream:
> > > >
> > > > INPUT:
> > > >��%PDF-1.3
> > > > %����
> > > > 80 0 obj
> > > > <<
> > > > /Linearized 1
> > > > /O 83
> > > > /H [ 3683 604 ]
> > > > /L 1427456
> > > > /E 465503
> > > > /N 4
> > > > /T 1425738
> > > > >>
> > > > endobj
> > > >������������������������������������������������������xref
> > > > 80 134
> > > > 0000000016 00000 n
> > > > 0000003029 00000 n
> > > >
> > > > OUTPUT:
> > > > &�Y
> > > > ST�L?ߺ�ݰ?�> "> �ݰ> EUR> ?%?> "> oe> �/��> EUR> oe>
> > > > �> EUR> oe> �> EUR> ��Y?>��^
> > > >
> > > > This is the code lines:
> > > > PdfReader pdfReader = new PdfReader("/prova/prova.pdf");
> > > > FileOutputStream streamFile = new FileOutputStream("/prova/output.pdf");
> > > > PdfStamper pdfStamper = new PdfStamper(pdfReader, streamFile);
> > > > AcroFields acroFields = pdfStamper.getAcroFields();
> > > > Set acroFieldsHashSet = acroFields.getFields().keySet();
> > > > Iterator iter = acroFieldsHashSet.iterator();
> > > > while (iter.hasNext()) {
> > > > String iterRead = (String)iter.next();
> > > > logger.info("letto da iter=="+iterRead);
> > > > acroFields.setField(iterRead,"prova","prova");
> > > > }
> > > > pdfStamper.close();
> > > >
> > > >
> > > > What can i do? Can u help me?
> > > >
> > > >���Thanks
> > > >���Claudio
> > > >
> > > >
> > > > -------------------------------------------------------
> > > > This SF.net email is sponsored by: Perforce Software.
> > > > Perforce is the Fast Software Configuration Management System offering
> > > > advanced branching capabilities and atomic changes on 50+ platforms.
> > > > Free Eval! http://www.perforce.com/perforce/loadprog.html>
> > > > _______________________________________________
> > > > iText-questions mailing list
> > > > [EMAIL PROTECTED]
> > > > https://lists.sourceforge.net/lists/listinfo/itext-questions
> >
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions