[Seaside] View PDF in browser

bobn at rogers.com bobn at rogers.com
Sun Dec 18 18:29:54 UTC 2011

The question of how to serve a PDF document has been asked and answered a few times, but not the question of how get the browser to view the PDF without launching a reader app for browsers configured to do that for PDF links. 

For example, if I create a PDF document and load it into my WAFileLibrary subclass, I can reference it with a simple anchor url: ... 
html anchor url: TSwaFileLibrary / #TestReportPdf; with: 'PDF Report File'.

<a href="/files/TSwaFileLibrary/TestReport.pdf">PDF Report File</a>

...which, when selected, displays it in the browser. 

If I generate the file response...
self requestContext respond: [:response |
document: byteArray 
mimeType: (Seaside.WAFileLibrary mimetypeFor: 'PDF')
fileName: 'IssueReport.PDF']
...and use a callback...

html anchor callback: [self pdfReport]; with: 'PDF Report Build'.
<a href="/Issues?_s=tkTzO72EQJbWMxF_&_k=SZ5ABAiSyHAfmzFW&79">PDF Report Build</a>

...I get a PDF reader opening on a file download.

So, I though be cleaver and build a RESTful url for the report (handy for sending links instead of content) which looked like '/blah blah blah.PDF'...
html anchor url: '/Issues?Report=TEST&filter=assigned:Bob_N.|status:open&filename=IssueReport.PDF'; with: 'PDF Report Anchor'

<a href="/Issues?Report=TEST&filter=assigned:Bob_N.|status:open&filename=IssueReport.PDF">PDF Report Anchor</a>

...which also opens a PDF reader on a file download.

Using #target: or WAPopupAnchorTag to open a new browser tab also did not work. 

Given that the href="/files... anchor works, it seems like this could work. 
I'd be grateful for any suggestions.

BTW: I'm using Christian Haider's pdf4smalltalk to build the PDF document. It rocks. 

Bob Nemec
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20111218/6df4e684/attachment.htm

More information about the seaside mailing list