locked
Print DirectX/Xaml Interop UI

    Question

  • Hi,

    My application uses SurfaceImageSource to show DirectX and Xaml UI elements. The application UI should be printed out as XPS/PDF. I've tried use PrintManager and PrintDocument. However, most Xaml elements can be printed except SurfaceImageSource which prints nothing. Another way is using PrintManager and ID2D1CommandList. But it is only for printing DirectX. Any good method to print both Xaml and DirectX?

    Thanks. 

    Thursday, March 28, 2013 12:55 PM

All replies

  • Hello,

     

    Thanks for your feedback, I will involve more experts to investigate it.

     

    Best regards,

    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, March 29, 2013 2:26 AM
  • Hi,

    how about using SwapChainBackgroundPanel?

    you may share your repro sample on a public website like skydrive, then we can have a check.

    regards,

    Jenny

    Monday, April 01, 2013 6:17 AM
  • Hi Jenny,

    SwapChainBackgroundPanel always renders under other Xaml controls but our application has to show some DirectX UI on top. So it isn't suitable in our case. I did try to print SwapChainBackgroundPanel through PrintManager as well. However, because SwapChainBackgroundPanel must be the root element, I can't add it as a child of PrintDocument. It throws an exception.

    I will repro my sample on skydrive later.

    Thanks.

    Monday, April 01, 2013 10:41 AM
  • Hi,

    Here is my Sample modified from MSDN official C++ print sample.

    Basically, what I did is:

    1. In ScenarioOutput2.xaml.cpp, create a SurfaceImageSource object, draw a green rectangle and attach it on an Image object.
    2. Press print button and see preview. The image object inside preview shows nothing. 
    Tuesday, April 02, 2013 3:39 AM
  • I've tested a workaround and it works.

    Before printing, redraw DirectX UI elements to a bitmap (WICBitmap) and then assign this bitmap back to an Xaml image element. In the other word, I translate DirectX UI element to a Xaml image element by myself, instead of printing SurfaceImageSource directly.

    The sample: Direct2D and WIC Image Editor helps a lot. It saves time to learn how to draw D2D elements to a bitmap and use it in Xaml.


    • Proposed as answer by JennyLi-MSFT Monday, April 08, 2013 6:15 AM
    Wednesday, April 03, 2013 9:42 AM