WeBWorK Problems

GeoGebra in PDF

Re: GeoGebra in PDF

by Davide Cervone -
Number of replies: 0
Since we are in TeX mode, how to run the javascript to run the GGB API to get the base64 string? I'd go out looking for a perl module that can function like a headless browser.

You can use Chrome (version 59 and above) in a headless mode to do this type of thing. See Google's getting started page for that.

It looks like you can use the WWW:Mechanize::Cheom to drive headless chrome from perl. But if that doesn't work well, there is a Node.js module called Puppeteer bug Google (described in the link above) that you could use (by running a node.js program as an external command from perl). That is less efficient, and would require yet another dependency for WeBWorK (node), but it might work.

Or you might just be able to get away with running headless chrome directly (examples for creating screen snapshots are in the link above).

Is it going to be a security concern to enable WW problems to activate a headless browser?

Probably, but I can't think of an exploit off the top of my head.

Once I have the base64, how to bring it to life as an image in the tex? I'd go looking for perl modules that could decode the base64 and write it as a temporary file, and include the image in the tex in the usual way.

If you use headless Chrome with screen snapshots, you should get a png file directly. If you use javascript in the page to get a base64 encoding sent back to you, then you would have to do as you suggest. The MMIME::Base64 module should do that for you.