Print/Page Break

I have created a single page that dynamically adds five containercontrols that is essentially a mini calendar for each day of the work week (imagine 5 of these boxes stacked on a web page). The data is pulled from another system and populated. I’ve been asked to now add “printer friendly” capability that neatly does a page break after one of the containercontrols. I’ve racked my brain, did some tests, and searched the web for a solution to this problem. There are really nice CSS solutions (link), but I can’t seem to input a

where I need it in the page.

Does anyone have a solution that they might be able to point me towards?

Thank you in advance!!!

[quote=283316:@Robert Litchfield] I’ve been asked to now add “printer friendly” capability that neatly does a page break after one of the containercontrols.
Does anyone have a solution that they might be able to point me towards?[/quote]

Don’t bother trying to insert page breaks. BTW

is not a page feed in HTML. See http://www.w3schools.com/cssref/pr_print_pageba.asp which could be placed into a pageSource control.

Instead, create a new page exactly sized to print neatly on one sheet of paper, and open it in a new window/tab.

Use a link with the target “New Window”, and point to your app with an argument that indicate which page to display. For instance :

This in the link will open a new window on your app, with argument to tell the app what to display :

Public Sub Open() Handles Open me.URL = "http://"+session.header("host")+"/?Page=2" End Sub

This in the Session Open event will display the proper page :

Public Sub Open() Handles Open if me.URLParameterExists("page") then select case me.URLParameter("page") case "2" WebPage2.show end select end if End Sub

Michel,
I was hoping to avoid doing what you suggest as that will take more effort. :frowning: Unless someone can come up with another idea, I will use the PDF functionality of the GraffitiSuite to build the exact output.

Regarding

, I only added that as a place holder for this discussion. In my code I would use
and some CSS to instruct the browser to insert the page break at this
.

RJL

As I said, place that code into a PageSouce onto each WebContainer and set the pageSource as After Content.

Michel,
The Xojo documentation indicates that we shouldn’t be adding PageSource to a WebContainer, only to a WebPage. That would indicate that this code could break in future versions of Xojo.

[quote]WebPageSource cannot be used with a WebDialog or WebContainer. It is for use with WebPage classes only. The IDE does not currently enforce this but it will eventually.
http://documentation.xojo.com/index.php/WebPageSource
[/quote]

[quote=283568:@Robert Litchfield]Michel,
The Xojo documentation indicates that we shouldn’t be adding PageSource to a WebContainer, only to a WebPage. That would indicate that this code could break in future versions of Xojo.[/quote]

Then use a WebSDK custom control. See WebSDK.PDF in the WebSDK folder, inside the Extras folder, next to the Xojo executable.

I’ve created a new small project that has nothing but two webtextfields with my newly minted CustomControl in between them. It looks good when I look at the source through the browser, but still no luck on the printing.

In the App.HTMLHeader I put:

<style type=“text/css”> @media print {.tPageBreak {page-break-after: always;}} </style>

In my CustomControl.SetupHTML I put (note: the TEST text in the

is simply to see that it is positioned correctly):

return "<div id=""" + self.controlID + """><div id=""tPageBreak"" class=""tPageBreak"" style=""position:absolute"">TEST</div></div>"

The

ends up where it should…but the print breaks are not occurring. :frowning: So far this is as close as I’ve gotten to a solution.

You do not need to create a separate style. It can be affected to the div directly :
https://www.lvsys.com/how-to-add-page-breaks-to-html-in-articles

Haha…I was just looking at that exact page.

When I build an HTML page in TextWrangler, it works exactly as I would expect.

[code]

Break after this line

second line

[/code]

When I add the two

lines to my CustomControl in the simple web app…nothing (though the text shows up as expected). There must be something in the Framework that is interfering with the ability to print. Can someone from Xojo jump in? Maybe I need to call support on this one.

I’ve uploaded my little test Xojo app to DropBox. DropBox

ok, first of all this css selector is only partially supported in recent browser versions. You can see that here:

http://caniuse.com/#search=page-break

But here’s the real problem:

http://www.w3schools.com/cssref/pr_print_pageba.asp

The Xojo Web Framework uses absolutely positioned elements.

Greg, thank you for letting me know that it is the framework, not some incorrect coding on my side. :slight_smile: Do you have a suggested alternative to formatted printing that will work with the web framework? From what I can deduce is that I either need to create a stand-alone HTML page that does not use the framework, or a 3rd part PDF creator.

what if you use relative positioning on your element? Set it’s style in the HTMLHeader for the app like so:

.myPageBreakStyle{ position: relative !important; }

where myPageBreakStyle is the same name as the Xojo webstyle assigned to the element.

Admittedly I really don’t remember off the top of my head how a relatively-positioned element will behave with other abs positioned elements but it might be worth a try… There are SO VERY MANY ways of doing things with CSS that it seems there should be a solution out there somewhere.

All depends on the complexity of your pages, and the result you want to obtain, but serving regular HTML using HandleURL is a relatively easy task.

Then you get back to the kind of solution I described above, where the user is presented with a link to display the printable content in a new tab/Window and print from that.

Thank you for your suggestions Michel. While I’m disappointed that the Framework does not support the CSS print functionality, at least there are work arounds.

It’s not that it doesn’t. If you print, you do get data printed to the page, it’s just that page breaks don’t work the way you expect.

I suggest filing a feature request.