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?
[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]
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. 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
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.
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
Greg, thank you for letting me know that it is the framework, not some incorrect coding on my side. 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.
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.