How to assign source when using RenderPageToSurface


  • I am trying to build simple PDF viewer in which i generate all image from pdf on physical path and assign to image. on user interaction i suppose to use RenderPageToSurface  to zoom it instead of creating a physical file but i don't understand how to assign this source to image that contains physical path. 
    Thursday, May 1, 2014 11:51 AM

All replies

  • Hi,

    RenderPageToSurface is the method to use when rendering PDF content to either a XAML SurfaceImageSource or VirtualSurfaceImageSource. The RenderPageToSurface method takes a PdfPage as an input parameter along with an instance of DXGISurface to which to draw the content, an offset on the device to draw and an optional PDF_RENDER_PARAMS structure. 

    For Rendering PDF Content in Windows Store Apps i suggest you should see the blog below: http://msdn.microsoft.com/en-us/magazine/dn532207.aspx

    And see the samples:


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, May 2, 2014 2:18 AM
  • Hi Anne Jing,

    Thanks for your reply.

    I need to create an image (or a binary stream of image) of any single page in a PDF.

    And I need to use "RenderPageToDeviceContext" for this purpose as I came to know that its the better (and faster) way to do this kind of stuff. 

    But am just not able to get enough help online to use this method. 
    Can you please provide me any sample (or link to any sample page) to get this task done?

    Thanks in advance.

    Saturday, May 3, 2014 10:58 AM
  • Hi there, 

    Writing a sample based on your requirement is out of forum scope, but you may refer to the sample from the post: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/1b1a4444-5db1-491f-9437-34358ae7e6ed/ipdfrenderernative-wrong-render-target-exception?forum=winappswithcsharp , if further help needed, you should submit a a support case on portal http://msdn.microsoft.com/en-US/windows/apps/hh690938 



    Tuesday, May 6, 2014 6:33 AM
  • Hello ,
    Thanks For Reply.
    As you say I have tried out this Sample. To apply zoom to Page I have Applied logic it is working fine on my PC but as i tried to run on surface tablet it gives me the following exception :

    System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
       at DirectX.ISurfaceImageSourceNative.BeginDraw(RECT updateRect, IDXGISurface& surface, POINT& offset)
       at DirectX.Renderer.RenderPage(PdfPage page, SurfaceImageSource imageSource, Int32 zoomfactor)
       at DirectX.Renderer.DrawPageAsync(PdfPage page, SurfaceImageSource imageSource, Int32 zoomfact)
       at IPdfRendererNativeTest.PageViewModel.DrawPage()
       at IPdfRendererNativeTest.PageViewModel..ctor(PdfPage page, Int32 zoomfact)
       at IPdfRendererNativeTest.MainPage.scrview_ViewChanged(Object sender, ScrollViewerViewChangedEventArgs e).

    And I can not understand how to resolve this.

    • Edited by Tanvi03 Friday, May 9, 2014 7:28 AM
    Friday, May 9, 2014 7:26 AM