Project

General

Profile

Printing a part of the application

Added by Gianluca Sorrentino over 14 years ago

Hi,

i'm looking for a way to allow the application's users to print some information and widgets regardless of the status of the application GUI.

How may i do this?

Thanks

Gianluca


Replies (4)

RE: Printing a part of the application - Added by Dushan Savich over 14 years ago

Gianluca Sorrentino wrote:

Hi,

i'm looking for a way to allow the application's users to print some information and widgets regardless of the status of the application GUI.

How may i do this?

Thanks

Gianluca

Hi Gianluca,

As far as I know , You can't do printing with Web Applications , in general .

Usually, Web Applications create reports PDF format, and then it's up to user to print it out.

Regards,

Dushan

RE: Printing a part of the application - Added by Gianluca Sorrentino over 14 years ago

Hi Dushan,

thanks for the quick reply.

In the WAnchor documentation i've found this example:

WResource *r = new PdfResource(this); // serializes to a PDF file.
a = new WAnchor(r, "PDF version", this);
a->setTarget(TargetNewWindow);

What is PdfResource? Does Wt offer a way to create a PDF file from a set of Widgets? If not, can you suggest me a way in doing it?

Regards,

Gianluca

RE: Printing a part of the application - Added by Wim Dumon over 14 years ago

Wt cannot render its widgets; it leaves that to a browser. PdfResource is not a Wt class, but merely a suggestion that you can use a WResource to implement a resource that returns a PDF. Usually, pdf documents are generated by some library that spits out pdf files (same for excell, word, ...). The advantage of this approach is that you can do different formatting for printed documents and the web browser.

That being said, I remember http://code.google.com/p/wkhtmltopdf/, which uses webkit to render a HTML page in a PDF document. Theoretically, we could modify Wt to invoke wkhtmltopdf to create a pdf of a user's currently visible session, but with a little modification maybe also of a specific widget... Maybe you can do some things with Wt::WWidget::htmlText(std::ostream &out) and wrap that in some HTML?

There are at least two problems with this approach:

  1. Widgets that call doJavaScript() will send the JavaScript to the browser, so it will only work for simple widgets without JavaScript.
  2. htmlText() resets variables in the widgets that cause the widget's updates to be propagated to the browser. It's safer not to call this on widgets that are part of your application's widget tree.
    In conclusion, I think you'd be the first to try this :-)

Regards,

Wim.

RE: save has pdf, xml or csv - Added by Roberto Rodríguez Reyes almost 14 years ago

any of you can help me with a simple example of application with funtions to save in these formats: .pdf, .xml and .csv

Thanks,

Roberto

    (1-4/4)