[Seaside] creating respons to feed into pdfcreator

Boris Popov, DeepCove Labs boris at deepcovelabs.com
Mon Jan 10 09:12:01 UTC 2011


That code is primarily to render XHTML to a string and then feed it to PRDreactor for conversion to PDF; returning of the bytes in the response is using #respond: as expected. My latest version looks like the following at the moment,

Component>>asPDF

| xhtml |
xhtml := (RenderCanvas builder)
		fullDocument: true;
		documentClass: WAHtmlDocument;
		rootBlock: 
			[:root |
			root beXhtml10Strict.
			root style add: (Styles default documentForFile: 'print.css').
			root style add: 'svg {-ro-replacedelement: ''com.realobjects.xml.formatters.SVGFormatter'';}'];
		render: [:html | html render: self].
^(PDFreactorClient default convertXHTML: xhtml) bytes
 
-Boris

-- 
DeepCove Labs Ltd.
+1 (604) 689-0322
4th floor, 595 Howe Street
Vancouver, British Columbia
Canada V6C 2T5
http://tinyurl.com/r7uw4

PacNet Services (Europe) Ltd.
+353 (0)61 714-360
Shannon Airport House, SFZ
County Clare, Ireland
http://tinyurl.com/y952amr

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message header. Unless otherwise indicated, it contains information that is private and confidential. If you have received it in error, please notify the sender and delete the entire message including any attachments.

Thank you.


-----Original Message-----
From: seaside-bounces at lists.squeakfoundation.org [mailto:seaside-bounces at lists.squeakfoundation.org] On Behalf Of Philippe Marschall
Sent: 09 January 2011 10:09
To: avanschijndel at oxius.nl; Seaside - general discussion
Subject: Re: [Seaside] creating respons to feed into pdfcreator

2011/1/6 a van schijndel <avanschijndel at oxius.nl>
>
> Hi,
>
> I am updating my application to seaside30. To create pdf I use prince2 executable.  The htmlcontent to feed into the prince executable is created with  a construction as described in http://www.seaside.st/documentation/pdfs in the section of pdfReactor at message asPDF .
> I am trying to understand how to do this in seaside30 but have trouble to find a way to do it now the respons is generated using a notification and response is only accessible via (current)requestContext.
>
> original example:
>
> asPDF
>   | handler response |
>   handler := WARenderContinuation root: (PDFRoot for: self).
>   response := WAResponse new.
>   handler context: (WARenderingContext new session: self session; actionUrl: WAUrl new; yourself).
>   handler processRendering: response.
>   ^(PDFReactorClient default convertXHTML: response contents contents) getPDF.

That's really strange code. I would do something like this:

answerPdf
    self requestContext respond: [ :response |
        response
            contentType:'application/pdf'
            attachmentWithFileName:'usecase.pdf';
            binary;
            nextPutAll: thePdf ]


renderContentOn: html
    html anchor
        callback: [ self answerPdf ]
        with: 'donload PDF'

However that doesn't cover how the PDF is actually created. I have no idea how PDFReactor works, does it render the current or an other page as HTML send it to a server and get it back as PDF?

Cheers
Philippe
_______________________________________________
seaside mailing list
seaside at lists.squeakfoundation.org
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


More information about the seaside mailing list