I had the need to programatically print an XPS file, but a couple of hours of Google searches only returned examples of how to print TO an XPS file. It was extremely difficult to find how to send a XPS file to an actual physical printer. Eventually something turned up and the solution seemed to be the XpsDocument class. Look at this simplified example to see how easy it turned out to be: PrintDialog dlg = new PrintDialog(); XpsDocument xpsDoc = new XpsDocument(PATH_TO_YOUR_XPS_FILE_HERE, System.IO.FileAccess.Read); dlg.PrintDocument(xpsDoc.GetFixedDocumentSequence().DocumentPaginator, “Document title”); As you can see, reading a XPS file and then sending the contents to a printer is not very hard at all.
For a new project of mine I’m using a rich text editor called CKEditor. This is a highly configurable editor that, unfortunately, suffers from cluttered and not easily understandable documentation. I needed to change the generated HTML from the editor so that images that were resized not only had their size set as style attributes, but as query string variables. So I needed this: <img src=”http://yoursite.com/photo.jpg” style=”width:150px; height:200px;” /> to be output as this: <img src=”http://yoursite.com/photo.jpg?width=150&height=200″ style=”width:150px; height:200px;” /> That proved to be easier said than done, but after quite a lot of googling, asking on several forums, and getting some helpful (and some not helpful at all) replies, I finally ended up with the following: Put the following code into CKEditor’s config.js: CKEDITOR.on(‘instanceReady’, function […] Read more
Because I’m using Twitter, Facebook and Google+ I haven’t really made any good posts to my blog for a while. I’m trying to remedy this by taking my blog in a new direction. As a “Technology Enthusiast” I regularly get stuck in various situations where I have to do a lot of googling. Some times I can google for a week and not find a solution. When I finally do find a solution I’ve decided I should write about it on my blog so that others can (maybe) find the solution as well. So don’t be surprised when you see lots of technical stuff popping up on this blog instead of the usual ramblings about what happens (or not) in my life.