PDA

View Full Version : Printing and others


dsalama
05-30-2006, 06:09 AM
I thought I would ask one more time.

As I've read, the browser cannot print flash movies. Therefore, any printing support from within a flash movie has to be done within the flash itself.

I have been reading through the docs and could not find any reference to printing support from within Laszlo apps. I searched through the wiki and found some references to a proposal to add printing support, but I don't think it's been done yet.

However, I see that LaszloMail does offer printing of messages and I REALLY would like to know how that's done. We're working on delivering an app to a client which must have printing support. We took the risk of doing it with Laszlo as we believe it's a great platform, even though we are still novices at it. We figured there is no better way to learn than to be put in front of the fire :)

The "others" part of the subject line refers to content returned by a back end application server. We are connecting our Laszlo app to a back-end via a REST-like API. However, there are some requests that the response from the server is either a CSV or XLS file or a PDF document. How can a Laszlo app handle these types of responses? At first, I thought of just launching an LzBrowser for the response and just let the browser handle the MIME type. Is that the correct approach? Is there a better one?

Anyway, any suggestions?

Thanks,
Daniel

hqm
05-30-2006, 12:05 PM
It is possible to use the Flash 7 printing API directly, although it has some restrictions in what it can print (alpha blending isn't handled properly I believe).

You can grab the underlying Flash movieclip from a Laszlo view, and print it using the Flash APIs.

I'm not sure what the Laszlo Mail app does however, it may reformat output as HTML for printing.

dnault
05-30-2006, 12:13 PM
I can answer one part of your question:
Originally posted by dsalama
I see that LaszloMail does offer printing of messages and I REALLY would like to know how that's done.
Laszlo Mail uses a hidden frame.

The frame's "onload" attribute has a piece of JavaScript that prints the contents of the frame. (Looking at this code for the first time, I notice that apparently the frame must acquire focus first. There's some special-case code to acquire focus in Safari; instead of focusing the frame, you can create a dummy form and focus on that instead.)

When the user hits the "Print" button, the client sets the location.href of the frame to a URL that hits the lzmail server. The server renders the message as HTML, then the frame's "onload" handler fires and prints the message.

dsalama
05-30-2006, 12:17 PM
Very interesting. A pain in the butt as a workaround but interesting.

Thanks,
Daniel