Here is an example showing how you could do it.
The script creates an element for the library to use and makes sure it is hidden. Then sends it to the library, does the rendering and finally extracts the results from it's "canvas" property into the drawing canvas plugin instance.
There is a little caveat to the whole process though. The drawing canvas is not available for use through the scripting API until at least 1 tick has passed, so the script in the example makes sure to wait for that.
Hopefully we will sort that out sometime in the near future, but until then you'll have to do with the little hack.