用户登录
用户注册

分享至

wpfdocumentviewerw

  • 作者: 小激动7925018
  • 来源: 51数据库
  • 2020-04-21

一、WPF DocumentViewer取某页内容,还显示其他页的部分内容,希望

WPF中使用DocumentViewer,中需要显示一个控件的内容,但控件高度超出页面高度,如何让控件分页显示?

大致代码如下:

FixedDocument fixedDocument = new FixedDocument();

Size pageSize = new Size(PAPER_SIZE_WIDTH, PAPER_SIZE_HEIGHT);

fixedDocument.DocumentPaginator.PageSize = pageSize;

PageContent pageContent = new PageContent();

FixedPage fixedPage = new FixedPage();

DetailsDataControl theDetailsDataControl = new DetailsDataControl() { DataContext = simulationRodLoadResult};

fixedPage.Children.Add(theDetailsDataControl);//theDetailsDataControl的高度超出fixedDocument 的页面高度

fixedPage.Measure(pageSize);

fixedPage.Arrange(new Rect(new Point(), pageSize));

fixedPage.UpdateLayout();

((IAddChild)pageContent).AddChild(fixedPage);

fixedDocument.Pages.Add(pageContent);

docViewer.Document = fixedDocument;

这时候的效果是:DocumentViewer会自动截去超出页面范围的部分.

我要的效果是:如果超出页面范围,应该该超出的部分放到下一页显示.

二、谁知道在wpf里vb.net or c#用DocumentViewer查看xps文件时不用Zoom

XPS 是 XML Paper Specification 的简称,它是微软公司开发的一种文档保存与查看的规范。以前的开发代号为 “Metro”。这个规范本身描述了这种格式以及分发、归档、显示以及处理 XPS 文档所遵循的规则。最为显著的特点是,XPS 所用的置标语言是 WPF 所用的 XAML 的一个子集,因此显示 Windows 应用程序所用的方法可以用于 XPS 文档。

人们认为 XPS 是 Adobe 公司的 PDF 的潜在竞争对手。但是,XPS 是一个静态文档格式,其本身不包括类似于 PDF 所具有的动态特性。

另外,团IDC网上有许多产品团购,便宜有口碑

三、wpf中关于打印预览的问题

FlowDocument doc2 = new FlowDocument();

doc2.Blocks.Add(DataTable);

FlowDocument doc = doc2;//(FlowDocument)XamlReader.Load(fs);

XpsDocument xpsDocument = new XpsDocument("test2.xps", FileAccess.ReadWrite);

XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(xpsDocument);

writer.Write(((IDocumentPaginatorSource)doc).DocumentPaginator);

// Display the new XPS document in a viewer.

docViewer.Document = xpsDocument.GetFixedDocumentSequence();

xpsDocument.Close();

四、请教在WPF中如何将控件实现打印预览

WPF可以使用VisualBrush将控件转换成一个Brush,你可以将这个Brush应用到任何你想使用的地方,比如控件的Background属性,Shape的Fill属性等

举个例子

如果使用XAML代码可以这样写

后台代码

VisualBrush brush=new VisualBrush(btn);

Border border=new Border();

border.Background=brush;

转载请注明出处51数据库 » wpfdocumentviewerw

软件
前端设计
程序设计
Java相关