How to get long HTML table onto Xojo page for multi-page printing?

I’m new to Xojo, and am building my first database-driven Web app at the moment. I’d like to create a printable report from the data, which when printed is likely to be several pages long. It looked like a good way to accomplish this might be to create a long HTML table containing the info to be printed. Creating the HTML source is not a problem and is working fine. Where I’m running into difficulties is with how to get it onto a Web page in Xojo.

I tried using an HTML Viewer control, but I couldn’t see any way of making it dynamically expand vertically to fit the HTML source - so if there’s too much data it gets truncated and a scroll bar is displayed. So no use for printing.

Next idea was to use a “PageSource” control. However, I’m having trouble getting my lovingly-created HTML into it! If I put a PageSource control on a Web page, and create an “Edit Source” Event Handler for it, containing the code:

Source = "<p>Hello there.</p>"

…then it works fine. But if I pass the aforementioned lovingly-created HTML to the Web page as a parameter to a Method, store the HTML in a String Property of the Web page with the Pagesource control on it, and then try to use my String Property’s contents as the source for my PageSource control, it displays nothing.

The problem seems to be - as far as I can see - something to do with the order in which things happen. It looks like the “EditSource” Event Handler is firing before the Method I’m calling has had a chance to put the HTML source into the Property. If this is correct, is there anything that can be done about it? Or would I be better using a different technique entirely to get my HTML table displayed as a multi-page printout? (without using third-party add-ons)

Thanks,

Dave

Hi David,

Xojo Web is not really designed for ad-hoc HTML tags. Everything is designed around the desktop metaphor so everything has exact positioning.

You can achieve your desired result but you would have to use the WebSDK. The WebSDK exposes events that let you emit HTML when the control is called. The controls will default to the top left until you overwrite the DOM and use absolute positioning to move them into position (to match the IDE).

With a little bit of effort you can make a Xojo web app responsive and feel like a traditional development stack. Good luck. :slight_smile:

Hi Phillip,

Thanks for your reply. I had a look at the WebSDK as you suggested. As I say, I’m really new to Xojo so learning curve is super-steep at the moment. I tried creating a control as per the docs, which uses JavaScript to change the content within the control after it’s initially been displayed, and that worked fine. But again, the content was all contained within the area of the control that I created on the page. If there’s more content that will fit, it gets truncated.

I found a solution to getting “PageSource” to work. I wrote some Xojo code in a Web page (called, say, WebPage1) to create the HTML I wanted to display on the second Web page (called, say, WebPage2). I arranged for the HTML source to be stored in a Public property on WebPage1, and then I could access that property from the “Edit Source” Event Handler for the PageSource control on WebPage2. That gets round the timing problem, and it works insofar as I now get some kind of display of the content I want on WebPage2. But now the displayed content is bounded by the browser window itself. If I look at the HTML source that the browser has received, I can see that Xojo is wrapping my raw HTML in various DIVs (XojoSession, XojoContainer, etc.), and so it’s still not going to work from a printing perspective.

Can you please give me a more specific pointer on the “events that let you emit HTML when the control is called” that you mentioned? Perhaps this is a way of persuading Xojo to spit out unadorned raw HTML just for this one report?

Thanks,
Dave

David, here is an entirely different approach : instead of trying to display HTML from a regular WebPage, it uses HandleURL to display pure HTML.

Here is the proof of concept project. Basically, place your HTML in the HTML property of Session, then in handleURL the program compares the path with what is encoded into the link.

You can have as many different HTML as there are sessions.

htmlpage.xojo_binary_project

Michel, that is brilliant - thank you so much! It does exactly what I want it to do, and very easy to implement.

Regards,
Dave