Working with Chris Sells on a project has certain “benefits” associated with it, and one of the big ones is his ability to find the right person in Microsoft that can help solve a problem. When he asked for a batch version of the Svg2Xaml tool, I said no problem, except that the Windows Client Print Driver has a pop up window that is looking for a file name to save the fixed document XAML file, and I couldn’t figure out a way to get it not to require it. Well, Chris was able to come up with a bit of code from Patrick Danino that we could use as a work around for now. It’s not the prettiest of solutions, and I believe MS will be improving the APIs for WCPD, but for now if you are using a System.Drawing.Graphics class and want to save it to a fixed format XAML doc, this is the only way to do it. Basically, you have to create your own PrintController that wraps the winspool Win32 dll, and it will save it to a file. Not the best of solutions, but it will work. Drawbacks are that it will only save it a file, not a stream (so you will need to use a temp file and convert it to a stream if that’s what you want), and the other major issue is that you can’t set Graphics object in the PrintPageEventArgs, only get it, and I don’t know of a way to clone a preexisting Graphics object to another preexisting Graphics object. If you want the code, you can download the class, plus example code off the Svg2Xaml project on GotDotNet.
The second tool is the example code, a command line version of the Svg2Xaml tool. It is a very basic tool, and only requires the SVG filename. You can download the binaries from the Svg2Xaml GDN project, or pull down all the Svg2Xaml code, plus the Svg2Xaml Console App.
DonXML Demsak