VisualsToXpsDocument BatchWrite和两个不同的视觉效果 [英] VisualsToXpsDocument BatchWrite and two different visuals

查看:147
本文介绍了VisualsToXpsDocument BatchWrite和两个不同的视觉效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的应用程序在很大程度上基于这个文件:http://download.microsoft.com/download/a/f /7/af7777e5-7dcd-4800-8a0a-b18336565f5b/xps-read.doc ,特别是标题为:将多个可视对象作为批处理写入

I have an extremely simple application based in large part on this document: http://download.microsoft.com/download/a/f/7/af7777e5-7dcd-4800-8a0a-b18336565f5b/xps-read.doc and in particular the section that is headed: Write multiple visual objects as a batch

我正在尝试的代码很简单,如下所示。问题是,第二页是空白而不是在其上有按钮,即使它实际上在文档中创建了第二页,就像它认为它做了它一样。在我的特定情况下,我将从阵列中打印网格,但这也不起作用所以我想要一个简单的案例来演示。只是侧面注释,它会产生第一个按钮两次,每个页面一次,如果你再次将其更改为B1和B1,则对应于B1,然后是批次写入中的B2。

The code I am trying is simple and shown below. The problem, the second page is blank instead of having the button on it even though it actually creates the second page in the document as if it thinks it did it. In my particular case I am going to be printing grids out of an array but that doesn’t work either so I wanted a simple case to demonstrate. Just a side note, it will produce the first button twice, once on each page, if you change it to B1 and B1 again vs B1 then B2 in the batchwrite.

当然这是一个过于简单的例子但是从我读到的每个视觉传入应该创建一个具有该视觉的新页面,安装.NET 3.0(我也尝试使用.NET 3.5)它不起作用,至少不像我预期的那样,或者样本表明它应该如此。我现在已经尝试了几天,对此有各种变化,到目前为止没有运气,我的搜索结果也没有任何结果。

Of course this is an oversimplified example but from what I read each visual passed in should create a new page with that visual, well with .NET 3.0 installed (I also tried with .NET 3.5) it doesn’t work, at least not like I expected it to or as the sample would indicate it should. I have been trying now for a couple of days with variations on this and so far no luck and my searches are not ending up with anything helpful either.

有人知道为什么第二页被创建但是空白或者如何让它包含视觉效果?

Does anybody know why the second page is created but is blank or how to make it contain the visual?

提前谢谢。


private void Window_Loaded(object sender, RoutedEventArgs e)
{


        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

Button B1 = new Button();
B1.Content =" One" ;;
Button B2 = new Button(); < br> B2.Content =" Two"

            Button B1 = new Button();
            B1.Content = "One";
            Button B2 = new Button();
            B2.Content = "Two";

File.Delete(@" C:\ Temp \ Test.xps");

            File.Delete(@"C:\Temp\Test.xps");

XpsDocument outXpsDoc = new XpsDocument(@"C:\Temp \ Test.xps",FileAccess.Write);

            XpsDocument outXpsDoc = new XpsDocument(@"C:\Temp\Test.xps", FileAccess.Write);

//为新文档创建文档编写器
XpsDocumentWriter XpsDocWrtr = XpsDocument.CreateXpsDocumentWriter(outXpsDoc);

            // create the document writer for the new document
            XpsDocumentWriter XpsDocWrtr = XpsDocument.CreateXpsDocumentWriter(outXpsDoc);

//创建"批次" writer
VisualsToXpsDocument XpsVisWriter =(VisualsToXpsDocument)XpsDocWrtr.CreateVisualsCollat​​or();

            // create the "batch" writer
            VisualsToXpsDocument XpsVisWriter = (VisualsToXpsDocument)XpsDocWrtr.CreateVisualsCollator();


XpsVisWriter.BeginBatchWrite();


            XpsVisWriter.BeginBatchWrite();

XpsVisWriter.Write (B1);
XpsVisWriter.Write(B2);

            XpsVisWriter.Write(B1);
            XpsVisWriter.Write(B2);

XpsVisWriter.EndBatchWrite();

            XpsVisWriter.EndBatchWrite();

outXpsDoc.Close();

            outXpsDoc.Close();

}

推荐答案

我在第一次看到的每一个视频都得到空白页面。对此有何答案?
i too am getting blank pages for every visual I write after the first. Any answer on this?


这篇关于VisualsToXpsDocument BatchWrite和两个不同的视觉效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆