Printing documents

Printing documents

by Robbie Newton -
Number of replies: 5

Don't know if this is the forum to ask this question, but can anyone tell me how a document (MS Word etc) can be printed.

So far I can see that a resource such as this can be opened up in a new window with scroll bars, status bar and toolbar etc. In this case the user can click on the print icon. Easy peasy!

However, if a resource is added to open in the moodle frameset, the toolbars (the one required anyway) etc. don't appear. We do get the 'track changes' toolbar which I assume is because of a policy/profile setting on our network?

Does anybody have any suggestions?

PS. We are running, WindowsXP clients (with Office 2003), Windows 2003 server, IIS, MySQL, PHP5

Average of ratings: -
In reply to Robbie Newton

Re: Printing documents

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Robbie,

To obtain a print icon, you may right-click the track changes toolbar then select the standard toolbar.

(AFAIK the track changes toolbar is courtesy of Internet Explorer, rather than any network settings. thoughtful)

PS You may be interested in Martin's Microsoft Office FAQ (simply follow the link). smile
In reply to Helen Foster

Re: Printing documents

by Robbie Newton -

Thanks for the Helen.smile

I'd managed to do that, however, if you remove the track changes toolbar first, you're then unable to add/remove any other toolbar.mixed

I was looking for a more robust solution, whereby a user (regardless of IT ability) would be able to perform this simple task.

We currently run Learnwise - this has an icon which allows users to print out the contents of the relevant frame. I was hoping that someone had thought of doing this in Moodle. mixed

In reply to Robbie Newton

Re: Printing documents

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

I was looking for a more robust solution, whereby a user (regardless of IT ability) would be able to perform this simple task.

We currently run Learnwise - this has an icon which allows users to print out the contents of the relevant frame. I was hoping that someone had thought of doing this in Moodle.

Not wanting anyone moving to Moodle to miss any cool Learnwise features wink, here's a hack that adds a print resource link to the navigation bar
e.g. Home >> Test course >> Resource >> Test resource (Print resource)

The print resource link is only added when the content of the frame is an uploaded file, as it's not possible to use javascript when the content comes from  a different site.

In mod/resource/type/file/resource.class.php (approx line 374) find

/// If we are in a frameset, just print the top of it

if (!empty($_GET['frameset']) and $_GET['frameset'] == "top") {

Following this line add

       $jsstring = "(<a href=\"javascript:if(parent.frames[1].location == 'about:blank') { alert('There is no document to print'); } else { parent.frames[1].focus(); parent.frames[1].print(); }\">Print resource</a>)";
$dodgyjavascripthack = '';
if ($resource->type == 'file') {
//browser security will prevent printing documents from other domains - so we add a couple of simple tests to determine if the link should be displayed
if (strpos($resource->reference, 'http://') === 0) {
$bits = @parse_url($resource->reference);
if (!empty($bits['host']) && $bits['host'] == $_SERVER['HTTP_HOST']) {
$dodgyhackjavascript = $jsstring;
}
} else {
$dodgyhackjavascript = $jsstring;
}
}

and modify the print_header line to be

print_header($pagetitle, $course->fullname, "$this->navigation ".format_string($resource->name) . ' ' . $dodgyhackjavascript, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent"));

(Thanks to Andy for this code. Please note that it's not been thoroughly tested! thoughtful)

In reply to Helen Foster

Re: Printing documents

by Sean Keogh -

Hi Helen,

Have you or Andy tried updating this to run with Microsoft's new IE7?  I have someone using the print hack - it was fine with IE6, but gives weird error messages on the printouts with IE7.  Unfortunately they don't have the option of using any other browser.

This is what they see on their printouts:

The document in this frame cannot be printed as laid out.

 

This frame will be printed separately

 

 

 

 

 

Print Error                       Page 1 of 1