Thx Peter,
i found a way with this:
public class PdfWriterTestPage
{
public StreamResponse onSubmit()
{
// Create PDF
InputStream is=generatePDF("Hello very nice world");
// Return response
return new PdfStreamResponse(is);
}
public InputStream generatePDF(String teststring)
{
// step 1: creation of a document-object
Document document = new Document();
ByteArrayOutputStream baos=new ByteArrayOutputStream();
try
{
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter.getInstance(document, baos);
// step 3: we open the document
document.open();
// step 4: we add a paragraph to the document
document.add(new Paragraph(teststring));
}
catch (DocumentException de)
{
System.err.println(de.getMessage());
}
// step 5: we close the document
document.close();
ByteArrayInputStream bais=new
ByteArrayInputStream(baos.toByteArray());
return bais;
}
class PdfStreamResponse implements StreamResponse
{
private InputStream is;
public PdfStreamResponse(InputStream is)
{
this.is=is;
}
public String getContentType()
{
return "application/pdf";
}
public InputStream getStream() throws IOException
{
return is;
}
}
}
Peter Schröder-2 wrote:
>
> hi sabine,
>
> i overlooked your topic!
>
> there are other possibilities in T5, you can use the SreamResponse to
> return a PDF via a listener!
> http://tapestry.apache.org/tapestry5/tapestry-core/guide/pagenav.html
>
> -----Ursprüngliche Nachricht-----
> Von: Ulrich Stärk [mailto:[EMAIL PROTECTED]
> Gesendet: Donnerstag, 10. Mai 2007 11:46
> An: Tapestry users
> Betreff: Re: AW: T5: Generate pdfs.
>
> Especially have a look at how to create your own service to output raw
> bytes instead of rendering a
> HTML page.
>
> Uli
>
> Peter Schröder schrieb:
>> hi sabine,
>>
>> take a look at http://www.agileskills2.org/EWDT/
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Sabine K. [mailto:[EMAIL PROTECTED]
>> Gesendet: Donnerstag, 10. Mai 2007 11:11
>> An: [email protected]
>> Betreff: T5: Generate pdfs.
>>
>>
>> Hello,
>>
>> i want to generate a pdf file from some textareas. To generate the pdfs i
>> want to use itext. Can u give me some hinds were i can get some
>> information
>> for generating pdfs?
>>
>> Best regards
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/T5%3A-Generate-pdfs.-tf3720491.html#a10410947
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]