Re: [iText-questions] Writing to ServletOutputStream

2010-02-22 Thread Sebastian Furth
Hi,

thank you so much! You were right - the problem was the JSP. Now I am using
a Servlet instead and everything works fine.

Once again thank you for your help, although it wasn't an iText Problem.

Best regards.

Sebastian Furth


2010/2/22 mkl 

>
> Sebastian,
>
>
> Sebastian Furth wrote:
> > I attached the pdf where the Graphics is missing. Maybe you can get some
> > information out of it.
>
> If you look at that PDF, you'll see that something along the lines of
> high-bit-shaving happened --- there are very many '?' characters at
> positions where characters with the high bit set can be expected.
> Therefore,
> some code seems to replace characters with the high bit set in the data you
> write to the ServletOutputStream.
>
> This might be your web application container falsely thinking only 7 bit
> output is legal. How to circumvent such a behaviour of your web application
> container is a valid question to news groups or mailing lists dealing with
> that very container.
>
> My guess would be that you have to explicitely tell it to expect 8 bit
> data.
>
> BTW, you of course don't call response.getWriter() before the code you
> posted here, do you? Only either getOutputStream or getWriter is allowed
> here...
>
> Regards,   Michael.
> --
> View this message in context:
> http://old.nabble.com/Writing-to-ServletOutputStream-tp27685496p27688899.html
> Sent from the iText - General mailing list archive at Nabble.com.
>
>
>
> --
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> ___
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> Check the site with examples before you ask questions:
> http://www.1t3xt.info/examples/
> You can also search the keywords list:
> http://1t3xt.info/tutorials/keywords/
>
--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Re: [iText-questions] Writing to ServletOutputStream

2010-02-22 Thread mkl

Sebastian,


Sebastian Furth wrote:
> I attached the pdf where the Graphics is missing. Maybe you can get some
> information out of it.

If you look at that PDF, you'll see that something along the lines of
high-bit-shaving happened --- there are very many '?' characters at
positions where characters with the high bit set can be expected. Therefore,
some code seems to replace characters with the high bit set in the data you
write to the ServletOutputStream.

This might be your web application container falsely thinking only 7 bit
output is legal. How to circumvent such a behaviour of your web application
container is a valid question to news groups or mailing lists dealing with
that very container.

My guess would be that you have to explicitely tell it to expect 8 bit data.

BTW, you of course don't call response.getWriter() before the code you
posted here, do you? Only either getOutputStream or getWriter is allowed
here...

Regards,   Michael.
-- 
View this message in context: 
http://old.nabble.com/Writing-to-ServletOutputStream-tp27685496p27688899.html
Sent from the iText - General mailing list archive at Nabble.com.


--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


Re: [iText-questions] Writing to ServletOutputStream

2010-02-22 Thread 1T3XT info
Mike Marchywka wrote:
> 
> LOL, I don't imagine this will help, but the high bit is probably being set 
> to zero.

That's exactly what happened.
It's described in both the 1st and 2nd edition of "iText in Action".

1st edition: page 642-643

I can’t repeat it enough: It’s a bad idea to use JSP to generate binary 
content. I don’t say it isn’t possible to integrate iText in a JSP page.
...
Some servers assume that JSP output isn’t binary, so you get the 
questionmark problem mentioned earlier. PDF files written to the file 
system of the server open without problems. When served to a client, the 
PDF opens, but you only see blank pages.

2nd edition: chapter 9

It's a bad idea to use JSP to generate binary content. That's considered 
improper use of the technology. JSP wasn't created to produce images, 
PDF files, nor any other binary file type.
...
It's possible that the PDF opens when served on the client, showing 
nothing but blank pages. Some servers assume that JSP output isn't 
binary, and every byte higher than 127 will show up as a question mark.

--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


Re: [iText-questions] Writing to ServletOutputStream

2010-02-22 Thread 1T3XT info
Sebastian Furth wrote:
> Of course it were good hints - the problem is me :)
> 
> OK I try to explain my problem:
> 
> I have created a JSP-Servlet which shall return a PDF Document on request.

That's the problem!!!

I opened your PDF in a text editor. This is what I saw:
1 0 obj
<>>>/Subtype/Form/BBox[0 0 600 
1550]/Matrix [1 0 0 1 0 0]/Length 4827/FormType 1/Filter/FlateDecode>>stream
x??]MsW?q?886f???l?;?GjLRc??o???d}q(?m?t???~?j???,fR?wg?cK?x?sNk????Tb?a?h?e\P^?D:?"H??.??J

34??wY?w??Ct?K?\??+?1???~???G?"e?h&???t??E??f:g?1?mv?H?)c?3??c;?0????Q??

Do you see all these question marks? Those are "shaved bytes". Who 
shaved these bytes? JSP did! Compare the file with the correct PDF and 
you'll see that there are much less question marks.

> Thank you in advance!

Throw away your JSP as far as possible and replace it with a Servlet!
If you have ever followed a course about JSP, you should have been 
taught that JSP IS NOT SUITED TO CREATE BINARY DATA. It's like eating 
soup with a fork instead of with a spoon.

If you really insist on using JSP, you need configure your application 
server so that JSP doesn't treat binary data as non-binary data.

--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


Re: [iText-questions] Writing to ServletOutputStream

2010-02-22 Thread Mike Marchywka


LOL, I don't imagine this will help, but the high bit is probably being set to 
zero. Whoever is creating all
those content attach/disposition things probably doesn't know it is not text. 

marchywka:/home/marchywka# od -ax  Desktop/Car-Diagnosis_Visualization.pdf | 
sed -e 's/ /\n/g' | grep "^$" | cut -c 1 | sort | uniq -c
    152 0
    146 1
    273 2
   1537 3
    202 4
    194 5
    327 6
    215 7
marchywka:/home/marchywka# 





> Date: Mon, 22 Feb 2010 15:30:21 +0100
> From: sebastian.fu...@googlemail.com
> To: itext-questions@lists.sourceforge.net
> Subject: Re: [iText-questions] Writing to ServletOutputStream
>
> Of course it were good hints - the problem is me :)
>
> OK I try to explain my problem:
>
> I have created a JSP-Servlet which shall return a PDF Document on request.
>
> //Get the file content
> ByteArrayOutputStream bstream = 
> de.d3web.empiricalTesting.caseVisualization.jung.JUNGCaseVisualizer.getInstance().getByteArrayOutputStream(t.getRepository());
>
>
> //Response
> response.setContentType("application/pdf");
> response.setHeader("Content-Disposition", 
> "attachment;filename=\""+filename+"\"");
>
> response.setContentLength(bstream.size());
>
> //Write the data from the ByteArray to the ServletOutputStream of the response
> bstream.writeTo(response.getOutputStream());
> response.flushBuffer();
>
>
> The pdf document is created by iText and should contain a graph (Graphics2D 
> Object).
>
> init(cases);
>
> int w = vv.getGraphLayout().getSize().width;
> int h = vv.getGraphLayout().getSize().height;
>
>
> ByteArrayOutputStream bstream = new ByteArrayOutputStream();
> Document document = new Document();
>
> try {
>
> PdfWriter writer =
> PdfWriter.getInstance(document, bstream);
>
> document.setPageSize(new Rectangle(w, h));
> document.open();
>
> PdfContentByte cb = writer.getDirectContent();
> PdfTemplate tp = cb.createTemplate(w, h);
> Graphics2D g2 = tp.createGraphics(w, h);
>
> paintGraph(g2);
>
> g2.dispose();
> tp.sanityCheck();
> cb.addTemplate(tp, 0, 0);
> cb.sanityCheck();
>
> document.close();
>
>
> } catch (DocumentException e) {
> Logger.getLogger(this.getClass().getName())
> .warning("Error while writing to file. The file was not created. " + 
> e.getMessage());
>
> }
>
> return bstream;
>
> If I delegate the ByteArrayOutputStream created in the method posted above to 
> a FileOutputStream the pdf has the desired content - but If I delegate it to 
> a ServletOutputStream the content (the Graphics2D Object) is missing.
>
>
> I attached the pdf where the Graphics is missing. Maybe you can get some 
> information out of it.
>
> Thank you in advance!
>
> Best regards
>
> Sebastian Furth
>
>
> 2010/2/22 1T3XT info>
>
> Sebastian Furth wrote:
>
>> Once again, thanks for your reply. Unfortunately I think I don't have
>
>> enough experience to understand your hints :)
>
>
>
> It were good hints though; I thought everybody knew wget.
>
>
>
> If possible, can you explain your problem as good as Mike explained how
>
> to use wget? For instance: save the PDF on your local system and open it
>
> using a text editor such as Notepad++, Wordpad,... What do you see?
>
>
>
> --
>
> Download Intel® Parallel Studio Eval
>
> Try the new software tools for yourself. Speed compiling, find bugs
>
> proactively, and fine-tune applications for parallel performance.
>
> See why Intel Parallel Studio got high marks during beta.
>
> http://p.sf.net/sfu/intel-sw-dev
>
> ___
>
> iText-questions mailing list
>
> iText-questions@lists.sourceforge.net
>
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
>
>
> Buy the iText book: http://www.1t3xt.com/docs/book.php
>
> Check the site with examples before you ask questions: 
> http://www.1t3xt.info/examples/
>
> You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
>
>
  
_
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
http://clk.atdmt.com/GBL/go/201469229/direct/01/
--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


Re: [iText-questions] Writing to ServletOutputStream

2010-02-22 Thread Klas Lindbäck
I am doing in a similar way. The only notable difference is the response 
header.

I use the following, which works in both IE and Firefox:

response.setHeader("Content-Disposition", "*inline*; 
filename=form.pdf");


/Klas
--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Re: [iText-questions] Writing to ServletOutputStream

2010-02-22 Thread Sebastian Furth
Of course it were good hints - the problem is me :)

OK I try to explain my problem:

I have created a JSP-Servlet which shall return a PDF Document on request.

//Get the file content
ByteArrayOutputStream bstream =
de.d3web.empiricalTesting.caseVisualization.jung.JUNGCaseVisualizer.getInstance().getByteArrayOutputStream(t.getRepository());

//Response
response.setContentType("application/pdf");
response.setHeader("Content-Disposition",
"attachment;filename=\""+filename+"\"");
response.setContentLength(bstream.size());

//Write the data from the ByteArray to the ServletOutputStream of
the response
bstream.writeTo(response.getOutputStream());
response.flushBuffer();

The pdf document is created by iText and should contain a graph (Graphics2D
Object).

init(cases);

int w = vv.getGraphLayout().getSize().width;
int h = vv.getGraphLayout().getSize().height;

ByteArrayOutputStream bstream = new ByteArrayOutputStream();
Document document = new Document();

try {

PdfWriter writer =
PdfWriter.getInstance(document, bstream);
document.setPageSize(new Rectangle(w, h));
document.open();

PdfContentByte cb = writer.getDirectContent();
PdfTemplate tp = cb.createTemplate(w, h);
Graphics2D g2 = tp.createGraphics(w, h);
paintGraph(g2);

g2.dispose();
tp.sanityCheck();
cb.addTemplate(tp, 0, 0);
cb.sanityCheck();

document.close();

} catch (DocumentException e) {
Logger.getLogger(this.getClass().getName())
.warning("Error while writing to file. The file was not created.
" + e.getMessage());
}

return bstream;

If I delegate the ByteArrayOutputStream created in the method posted above
to a FileOutputStream the pdf has the desired content - but If I delegate it
to a ServletOutputStream the content (the Graphics2D Object) is missing.

I attached the pdf where the Graphics is missing. Maybe you can get some
information out of it.

Thank you in advance!

Best regards

Sebastian Furth


2010/2/22 1T3XT info 

> Sebastian Furth wrote:
> > Once again, thanks for your reply. Unfortunately I think I don't have
> > enough experience to understand your hints :)
>
> It were good hints though; I thought everybody knew wget.
>
> If possible, can you explain your problem as good as Mike explained how
> to use wget? For instance: save the PDF on your local system and open it
> using a text editor such as Notepad++, Wordpad,... What do you see?
>
>
> --
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> ___
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> Check the site with examples before you ask questions:
> http://www.1t3xt.info/examples/
> You can also search the keywords list:
> http://1t3xt.info/tutorials/keywords/
>


Car-Diagnosis_Visualization.pdf
Description: Adobe PDF document
--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Re: [iText-questions] Writing to ServletOutputStream

2010-02-22 Thread Mike Marchywka






> Date: Mon, 22 Feb 2010 15:14:55 +0100
> From: sebastian.fu...@googlemail.com
> To: itext-questions@lists.sourceforge.net
> Subject: Re: [iText-questions] Writing to ServletOutputStream
>
> Thanks for your reply!
>
> Is it possible that the ServletOutputStream "shaves" the upper bit from every 
> byte?
>
> I have a method which returns a ByteArrayOutputStream containing the pdf data.
> If I delegate this OutputStream to a FileOutputStream everything is ok but if 
> I use
>
> the ServletOutputStream there is no content in the pdf.
>
> If the ServletOutputStream is responsible for this do you have a idea how I 
> can
> prevent it from doing this?
>
javadocs claim it is for binary data but maybe you are using wrong method or 
manipulating bytes
as char or have subclassed, I dunno,

http://www.google.com/#hl=en&safe=off&q=site%3Asun.com+ServletOutputStream&aq=f&aqi=&oq=&fp=d95f0d161f018361





> Thank you in advance!
>
> Best regards.
>
>
> Sebastian Furth
>
>
>
> 2010/2/22 1T3XT info
>
> Sebastian Furth wrote:
>
>> Something happens during the request because it returns a pdf in the
>
>> dimension set in the code - but there is absolutely no content (blank).
>
>
>
> Sounds like the "blank page" problem described in the book (1st and 2nd
>
> edition). This happens if you "shave" the upper bit from every byte. The
>
> PDF structure is preserved, and as a result a viewer can show you all
>
> the pages of the PDF, the bookmarks, etc... But all binary data, for
>
> instance the page content stream, is made corrupt (of course: you've
>
> thrown away 1/8 of the information).
>
>
>
> If that's what's happening in your case, you have a configuration error
>
> somewhere.
>
>
>
> --
>
> Download Intel® Parallel Studio Eval
>
> Try the new software tools for yourself. Speed compiling, find bugs
>
> proactively, and fine-tune applications for parallel performance.
>
> See why Intel Parallel Studio got high marks during beta.
>
> http://p.sf.net/sfu/intel-sw-dev
>
> ___
>
> iText-questions mailing list
>
> iText-questions@lists.sourceforge.net
>
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
>
>
> Buy the iText book: http://www.1t3xt.com/docs/book.php
>
> Check the site with examples before you ask questions: 
> http://www.1t3xt.info/examples/
>
> You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
>
>
  
_
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
http://clk.atdmt.com/GBL/go/201469229/direct/01/
--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


Re: [iText-questions] Writing to ServletOutputStream

2010-02-22 Thread Mike Marchywka












> Date: Mon, 22 Feb 2010 14:56:45 +0100
> From: i...@1t3xt.info
> To: itext-questions@lists.sourceforge.net
> Subject: Re: [iText-questions] Writing to ServletOutputStream
>
> Sebastian Furth wrote:
>> Something happens during the request because it returns a pdf in the
>> dimension set in the code - but there is absolutely no content (blank).
>
> Sounds like the "blank page" problem described in the book (1st and 2nd
> edition). This happens if you "shave" the upper bit from every byte. The
> PDF structure is preserved, and as a result a viewer can show you all
> the pages of the PDF, the bookmarks, etc... But all binary data, for
> instance the page content stream, is made corrupt (of course: you've
> thrown away 1/8 of the information).
>
> If that's what's happening in your case, you have a configuration error
> somewhere.


cygwin has an octal dump utility(od iirc) , first few lines of output would at 
least
let you know if that is the problem. Offhand I don't know who would assume
you have text but again you'd have to think a wrong content type somewhere.
ByteArray of course is supposed to be just that, no text assumption but
if someone manipulates those there could be sign issues, all kinds of things
could happen. I just made a funny post on cygwin-talk list about 
that bit being used for parity only LOL.


>
> --
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> ___
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> Check the site with examples before you ask questions: 
> http://www.1t3xt.info/examples/
> You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
  
_
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
http://clk.atdmt.com/GBL/go/201469229/direct/01/
--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


Re: [iText-questions] Writing to ServletOutputStream

2010-02-22 Thread 1T3XT info
Sebastian Furth wrote:
> Once again, thanks for your reply. Unfortunately I think I don't have 
> enough experience to understand your hints :)

It were good hints though; I thought everybody knew wget.

If possible, can you explain your problem as good as Mike explained how 
to use wget? For instance: save the PDF on your local system and open it 
using a text editor such as Notepad++, Wordpad,... What do you see?

--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


Re: [iText-questions] Writing to ServletOutputStream

2010-02-22 Thread Sebastian Furth
Thanks for your reply!

Is it possible that the ServletOutputStream "shaves" the upper bit from
every byte?

I have a method which returns a ByteArrayOutputStream containing the pdf
data.
If I delegate this OutputStream to a FileOutputStream everything is ok but
if I use
the ServletOutputStream there is no content in the pdf.

If the ServletOutputStream is responsible for this do you have a idea how I
can
prevent it from doing this?

Thank you in advance!

Best regards.

Sebastian Furth


2010/2/22 1T3XT info 

> Sebastian Furth wrote:
> > Something happens during the request because it returns a pdf in the
> > dimension set in the code - but there is absolutely no content (blank).
>
> Sounds like the "blank page" problem described in the book (1st and 2nd
> edition). This happens if you "shave" the upper bit from every byte. The
> PDF structure is preserved, and as a result a viewer can show you all
> the pages of the PDF, the bookmarks, etc... But all binary data, for
> instance the page content stream, is made corrupt (of course: you've
> thrown away 1/8 of the information).
>
> If that's what's happening in your case, you have a configuration error
> somewhere.
>
>
> --
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> ___
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> Check the site with examples before you ask questions:
> http://www.1t3xt.info/examples/
> You can also search the keywords list:
> http://1t3xt.info/tutorials/keywords/
>
--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Re: [iText-questions] Writing to ServletOutputStream

2010-02-22 Thread 1T3XT info
Sebastian Furth wrote:
> Something happens during the request because it returns a pdf in the 
> dimension set in the code - but there is absolutely no content (blank).

Sounds like the "blank page" problem described in the book (1st and 2nd 
edition). This happens if you "shave" the upper bit from every byte. The 
PDF structure is preserved, and as a result a viewer can show you all 
the pages of the PDF, the bookmarks, etc... But all binary data, for 
instance the page content stream, is made corrupt (of course: you've 
thrown away 1/8 of the information).

If that's what's happening in your case, you have a configuration error 
somewhere.

--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


Re: [iText-questions] Writing to ServletOutputStream

2010-02-22 Thread Mike Marchywka


> Date: Mon, 22 Feb 2010 11:45:43 +0100
> From:
> To: itext-questions@lists.sourceforge.net
> Subject: [iText-questions] Writing to ServletOutputStream
>
> Hi,
>
> Please note that I postet links to pastie.org for better readability of the 
> code snippets.
>
> I am using iText to print graphs produced with the JUNG Framework to pdfs.
> To achieve this I have the following code:
>
>
> http://www.pastie.org/private/rsy6wzneedpvo4dai3vcgw
>
> Writing the graphics Object to the pdf is done by the following code:
>
> http://www.pastie.org/private/zgwocpvjih16j2cmcdmza
>
>
> The produced ByteArrayOutputStream is used to save the content to a file 
> (works great - I get a wonderful pdf):
>
> http://www.pastie.org/private/imxi9cmdrzowop9ivxgnba
>
>
> The reason why I am generating a ByteArrayOutputStream is that I additionally 
> want to write the created pdf content to a ServletOutputStream:
>
> http://www.pastie.org/private/r4h2lad26xbwjokoh0zbq
>
>
> unfortunately the only thing I get is a PDF document in the desired dimension 
> but blank - no content :( I am using almost the same code for writing text 
> content to a ServletOutputStream and I do get the content - so I think the 
> code of the response is ok. Is there a problem of writing 
> ByteArrayOutputStream content containing iText data to ServletOutputStreams? 
> It is really weird that everything works when I write the 
> ByteArrayOutputStream content to a FileOutputStream and don't get anything 
> when I write it to the ServletOutputStream :(
>


I didn't hit the links and I'm not sure what you mean by blank but do you set 
the server's content type to
something telling your browser it is pdf? If you hit your server with something 
more diagnostic than artistic,
like wget instead of IE, you can at least see what it thinks is going on- is 
the byte count right etc. You may
even be able to do some diffs and determine if there is truncation or 
corruption etc. Also check the servlet
debugging information which you hopefully generate :)





>
> It would be great if you could take a look at my code.
>
> Thank you in advance!
>
> Sebastian Furth
>
  
_
Hotmail: Powerful Free email with security by Microsoft.
http://clk.atdmt.com/GBL/go/201469230/direct/01/
--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


[iText-questions] Writing to ServletOutputStream

2010-02-22 Thread Sebastian Furth
Hi,

Please note that I postet links to pastie.org for better readability of the
code snippets.

I am using iText to print graphs produced with the JUNG Framework to pdfs.
To achieve this I have the following code:

http://www.pastie.org/private/rsy6wzneedpvo4dai3vcgw

Writing the graphics Object to the pdf is done by the following code:

http://www.pastie.org/private/zgwocpvjih16j2cmcdmza

The produced ByteArrayOutputStream is used to save the content to a file
(works great - I get a wonderful pdf):

http://www.pastie.org/private/imxi9cmdrzowop9ivxgnba

The reason why I am generating a ByteArrayOutputStream is that I
additionally want to write the created pdf content to a ServletOutputStream:

http://www.pastie.org/private/r4h2lad26xbwjokoh0zbq

unfortunately the only thing I get is a PDF document in the desired
dimension but blank - no content :( I am using almost the same code for
writing text content to a ServletOutputStream and I do get the content - so
I think the code of the response is ok. Is there a problem of writing
ByteArrayOutputStream content containing iText data to ServletOutputStreams?
It is really weird that everything works when I write the
ByteArrayOutputStream content to a FileOutputStream and don't get anything
when I write it to the ServletOutputStream :(

It would be great if you could take a look at my code.

Thank you in advance!

Sebastian Furth
--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

[iText-questions] writing to ServletOutputStream

2003-07-02 Thread Lloyd Bergman
I tired following the tutorial and passed a ByteOutputStream to PdfWriter
and then wrote that to a ServletOutputStream.  Ofcourse I had to use
setContentSize passing the length of my ByteOutputStream using its size
method like the tutorial said but I got a ProtocolException saying that I
exceeded the stated content length.  I eventually got it to work by playing
with fudge factors.  The fudge factor that worked was to add 100 to my
length so I guess I'm happy.  However, I am a little uncomfortable without
having any idea as to why this worked, specifically, why did I need to add
100?




---
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa0016ave/direct;at.asp_061203_01/01
___
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions