locked
PDF Api - RenderToStreamAsync returns an image with different width/height than destinationWidth/destinationHeight

    Question

  • Hello,

    I'm trying to render pdf using the pdf api and I have noticed that the image returned by the RenderToStreamAsync doesn't have the size I asks. Plus, this size seems to depend on the screen resolution and zoom factor.

    For my application, I am using the size to render only portion of the page, and I really need an image with the parameters I give.

    Is there any way to avoid this difference? (e.g. by setting an other parameter)

    Thanks.

    Thursday, March 13, 2014 2:45 PM

Answers

  • Hi BatRocchia,

    Sorry for a late response.

    Let's say if you generate a image by the returned IRandomAccessStream, you should be able to get the size of the image, and you can know if the image is rendered with a correct parameter.

    If the parameter is correct, I think the problem should be on your display, you resize the image while showing to the user, you could set Stretch property of the image as "None" to see if the size of image still not correct.

    If the parameter is not a correct one, plz feedback to us and I will try to give a test to validate if this could a bug or not.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" 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.


    Tuesday, March 25, 2014 6:57 AM
    Moderator

All replies

  • Hi BatRocchia,

    renderToStreamAsync(IRandomAccessStream, PdfPageRenderOptions) method enables you to render by PdfPageRenderOptions, where you could set DestinationHeight and DestinationWidth .

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" 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, March 14, 2014 6:39 AM
    Moderator
  • Yes, I am using those option to set the size of my image.

    BUT, the image result size does not always respect the size I asked. The final size depends on the screen resolution and screen zoom.

    I guess it is to get the best resolution for the image.

    Is there a way to get the image with the size asked? Not depending on the screen resolution or screen zoom?

    Friday, March 14, 2014 9:06 AM
  • Hi BatRocchia,

    Sorry for a late response.

    Let's say if you generate a image by the returned IRandomAccessStream, you should be able to get the size of the image, and you can know if the image is rendered with a correct parameter.

    If the parameter is correct, I think the problem should be on your display, you resize the image while showing to the user, you could set Stretch property of the image as "None" to see if the size of image still not correct.

    If the parameter is not a correct one, plz feedback to us and I will try to give a test to validate if this could a bug or not.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" 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.


    Tuesday, March 25, 2014 6:57 AM
    Moderator
  • I mark your answer as an answer, because i can deal with the display by setting the Stretch property to UniformToFill and by setting the Width/Height property to the size asked.

    However, the problem still exist. If I ask a certain size, depending on the screen resolution and zoom level, I have a different size.

    Of course I checked the image size by setting the Stretch property to None and, I checked the size of the return image by the RenderToStreamAsync function. If I have a certain screen resolution, but a zoom level of 140%, the size is different than if I have a zoom level of 100%. 


    Tuesday, March 25, 2014 12:27 PM