问题
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.

回答1:
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?
回答2:
You can add a ViewBox and put the image inside it. ViewBox size should be the size of your doc minus any margins needed
回答3:
Try setting
i.Height = bi.PixelHeight;
i.Width = bi.PixelWidth;
That should re-size i
according to the the image pixels.
来源:https://stackoverflow.com/questions/9495914/fixeddocument-page-size