Printing

Workarounds and usability notes.

Printing

Postby John Robin Dove » Tue Oct 06, 2020 7:57 am

Hi Clifton,
I want to allow users to print lists of students results, up to 40 lines on an A4 sheet of paper. Here is what I've done so far.
The results are presented like this:
Image
I open a sub-modal window and transfer the text to a field in this window. When the window opens I call window.print(). This works as planned but the result only occupies about less than half of the page.
Image
So I have tried increasing the font-size which looks rather strange in the sub-modal but that wouldn't matter if it worked as I intend to close the sub modal window again as soon as I can.
Image
The font-size seems more suitable but the text still doesn't fill the page. I don't know why.
Image
I'd be grateful for your help.
John

UPDATE

Just had a thought. It's probably too small because the field on the Toolbook page is tool small. However I can't make it bigger because the sub-modal cannot be bigger than the mainWindow. So maybe I should not use a sub-modal but open a new browser tab for a non-Toolbook HTML page? :idea:

UPDATE 2

So far, so good ...
Image
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Printing

Postby Clifton » Tue Oct 06, 2020 9:46 am

I would go with a new tab in this case to make sure results are as predictable as possible.
Also, you may want to explore using a print.css stylesheet. The reason why your previous attempt did not print the whole list is because the field type is "scrolling" when displayed in a browser window or in a subModal() dialog box. By loading a print.css, you can specify classnames that only get applied when a document goes to print. In this case you would remove set the classname of the field that contains your text to "overflow-y : visible;" so that you entire text shows. If you search on the Internet for how to use a print.css, you will likely find lots of good information.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Printing

Postby John Robin Dove » Wed Oct 07, 2020 8:35 am

Thanks for your help. The most important thing I have just learned is that to transfer textlines like this to an HTML document they must be placed in a pre element otherwise the line breaks disappear!
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Printing

Postby Clifton » Wed Oct 07, 2020 8:49 am

Good practice with textlines is to replace carriage returns with "<br>" tags so your content is HTML compatible.
Here is a quick way to make the conversion:
    var htmlText = text.replace(/\n|\r/g, "<br>");
BTW: The same method can be used to add other styling to the elements in your list. (e.g.: highlighting lines; making some words bold; changing color; etc.)
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Printing

Postby John Robin Dove » Wed Oct 07, 2020 9:27 am

OK. Thanks.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron