简体   繁体   English

FixedDocument页面大小

[英]FixedDocument page size

I am pulling an image from the web and adding it to a FixedDocument page. 我从网上提取图像并将其添加到FixedDocument页面。 The image that I am pulling has dimension size of 1200px X 1500px. 我所拉的图像尺寸为1200px X 1500px。 However in the FixedDocument the image appears as a small thumbnail (please see the screen grab). 但是在FixedDocument中,图像显示为一个小缩略图(请参阅屏幕抓取)。

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. 你可以在BitmapSource.DownloadCompleted事件处理程序中交叉检查图像大小,看看你是否得到了你想要的。

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. 据我所知,JPEG图像文件可以包含缩略图图像以便快速预览。 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. 这应该重新大小i根据该图像的像素。

You can add a ViewBox and put the image inside it. 您可以添加ViewBox并将图像放入其中。 ViewBox size should be the size of your doc minus any margins needed ViewBox大小应该是您的文档的大小减去所需的任何边距

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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