I have a list of things I consider essential functionality for a knowledge worker in a virtual world like Second Life or realXtend. One of the items on the top of the list is printing a notecard. The lack of printing functionality was reported a year ago in the Linden Lab JIRA database (VWR-391), but it has been a low priority bug because there is a workaround – copy all the text on the notecard, paste it into your favorite text editor outside Second Life and print it from there. It’s about as clunky as the machine below.
Extending the Second Life client to add printing functionality in the inventory GUI is a bit beyond me, but I thought I might be able to extend the realXtend server using its Python scripting extensions. For the last few evenings I’ve been exploring the issues. Here are some of the things I’ve run up against so far:
- realXtend is a scripting host for IronPython. The version of IronPython is not listed anywhere, but an examination of the DLLs shows that it is ver 18.104.22.168. That means it has some equivalency with Python 2.4.3. I filed a bug report with realXtend team to document the IronPython version number in release notes.
- Knowing that realXtend supports the Python 2.4 functionality we can search for modules that might be compatible. Pywin32 is available in different flavors including 2.4 and supports shell commands, so we might be able to start a shell to print a formatted text file containing content copied from a notecard.
- IronPython as hosted in realXtend lacks the site-packages directory, so I’m not sure how to install the modules. Furthermore, the installation process requires a working Python, so I think I have to install Python 2.4 and install the modules in its site-packages folder. The IronPython implementation includes a site.py script which can be modified to add other directories to the site path. (I still have to work out whether you can set IRONPYTHONPATH to refer to the additional libraries.)There’s actually a lot more to learn about installing packages. It seems there is an enhanced distribution of IronPython called FePy which includes the functionality of the site-packages folder and the standard package installation procedures. Whether there’s any way to replace the hosted IronPython with this by switching an re-registering DLLs is another exercise!
- Further reading suggests that pywin32 may not work in IronPython anyway, so I may need a backup plan using the .NET features of IronPython. Again, I could fire up a shell, but I might as well learn something about the XPS printing model. (Update 5/16: Pywin32 doesn’t work with IronPython 1.1.1 because it includes compiled C/C++ routines.)
- The XPS FlowDocument is well-matched to the simple notecard. It should be relatively easy for a Python script to iterate over the lines of a notecard and wrap the XML markup of a FlowDocument around the lines or paragraphs.
- I still have to understand and test how to initiate the printing of the XPS document on the server and direct the output to the default printer on my client, which is always a networked device (even at home).
- Last, and by no means least, I have to define an appropriate user interface. I’m leaning towards the idea of a realistic looking printer which I can rez from inventory wherever I am. It has a pie menu which lets me set which network printer I want to print to. In a later phase I would add portrait/landscape selection to the menu. To print a notecard, I would simply drag it from inventory to the printer.
I’m hoping that the approach described above gets around the limited functionality of LSL scripting, including restrictions on how much data can be moved over HTTP and XMLRPC connections, and in which direction it can go.
If you know of a better solution, please let me know. If anyone feels inspired to fix VWR-391 soon, that would be good too!