I did find a code-behind workaround to access the restricted Map content after all! The basic approach is to export dynamic and tiled service layers through the REST API to image streams and overlay the results in a WriteableBitmap. You can then render graphics layers and UIElements on top of that. Probably more work than just using a PDF browser extension, but what the heck.
Anyway, I've created a first draft of a PDF creation class and added it to the code gallery as well as my web site: http://www.pierssen.com/arcgis10/silverlight.htm 🙂
i = wbm.Pixels[0];(located on line 252) is throwing a handled error of type System.Security.SecurityException. The error is: "WriteableBitmap has protected content. Pixel access is not allowed." After research, I found out this is due to accessing maps from other sites. For example, if your base layers are coming from ESRI (and maybe Bing, I'm not sure), you'll get this error. This is due to the fact that WriteableBitmap has been prevented from accessing anything in another domain. Setting clientaccess.xml or crossdomain.xml doesn't seem to help.
I did find a code-behind workaround to access the restricted Map content after all! The basic approach is to export dynamic and tiled service layers through the REST API to image streams and overlay the results in a WriteableBitmap. You can then render graphics layers and UIElements on top of that. Probably more work than just using a PDF browser extension, but what the heck.
Anyway, I've created a first draft of a PDF creation class and added it to the code gallery as well as my web site: http://www.pierssen.com/arcgis10/silverlight.htm 🙂
Interesting. I haven't encountered that error myself, but I'm wondering if in your case it takes so long to create the image that the output stream provided by Silverlight is expiring. Try asking for the output PDF file right at the start of the PDF creation stage and see if that solves the problem.
SaveFileDialog savePDF = new SaveFileDialog(); savePDF.DefaultExt = ".pdf"; savePDF.ShowDialog(); System.IO.Stream PDFstream = savePDF.OpenFile(); PDFNew.SetOutputStream(PDFstream); PDFNew.DoExport();