Search code examples
c#wpfdimensionfixeddocument

FixedDocument page size


I am pulling an image from the web and adding it to a FixedDocument page. The image that I am pulling has dimension size of 1200px X 1500px. However in the FixedDocument the image appears as a small thumbnail (please see the screen grab).

Given below is the code snippet.

FixedDocument fd = new FixedDocument();

BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.UriSource = new Uri(@"http://www.example.com/image.jpg", UriKind.Absolute);
bi.EndInit();
Image i = new Image();
i.Source = bi;

FixedPage fixedPage = new FixedPage();
fixedPage.Children.Add(i);                

PageContent pageContent = new PageContent();
(pageContent as IAddChild).AddChild(fixedPage);
fd.Pages.Add(pageContent);

I need the image to appear as per its dimensions and not as a thumbnail. Please can someone let me know what needs to be done to show the image as per its size?

Many thanks.

enter image description here


Solution

  • Your code works fine for me with this large image.

    You could cross check the image size in a BitmapSource.DownloadCompleted event handler to see if you got what you wanted.

    Although, i would have no explanation why the image size would differ from what you expect. As far as i know JPEG image files can contain thumbnail images for fast preview. Perhaps your server is delivering such a thumbnail?