简体   繁体   中英

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.

在此输入图像描述

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?

Try setting

i.Height = bi.PixelHeight;
i.Width = bi.PixelWidth;

That should re-size i according to the the image pixels.

You can add a ViewBox and put the image inside it. ViewBox size should be the size of your doc minus any margins needed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM