Am trying to print visual on Microsoft XPS Document Writer using VisualsToXpsDocument.Write(). I am encountering following error on clicking the close (x button on top right) button of the "Save the file as" dialog box  -

Printing was canceled. Win32 error: The data area passed to a system call is too small.

The StackTrace for the same is -

at Microsoft.Internal.GDIExporter.CGDIRenderTarget.ThrowOnFailure(Int32 hr)
   at Microsoft.Internal.GDIExporter.CGDIRenderTarget.StartDocumentWithoutCreatingDC(String priterName, String jobName, String filename)
   at Microsoft.Internal.AlphaFlattener.MetroToGdiConverter.StartDocumentWithoutCreatingDC(String jobName)
   at System.Windows.Xps.Serialization.MXDWSerializationManager.EnablePassThru()
   at System.Windows.Xps.VisualsToXpsDocument.WriteVisual(Boolean asyncMode, PrintTicket printTicket, PrintTicketLevel printTicketLevel, Visual visual)
   at System.Windows.Xps.VisualsToXpsDocument.Write(Visual visual, PrintTicket printTicket)
   at LC.Classes.EventPrinting.PrintView(List`1 Visuals, String View)

Whats going wrong ?

Thanks!