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 <[email protected]>
> 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
> [email protected]
> 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 [email protected] 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/
