Pagination 呈现后处理Flowdocument页面
上面的代码没有发布任何内容。一旦对flowdocument进行分页并获取页面的可视化表示,可视化视图将引用flowdocument的内容。因此,既不会处理Visual文档,也不会处理flowdocument的内容。 上述代码在执行时会不断从内存中溢出 有人知道如何释放所有这些资源所持有的内存吗Pagination 呈现后处理Flowdocument页面,pagination,out-of-memory,flowdocument,xpsdocument,fixeddocument,Pagination,Out Of Memory,Flowdocument,Xpsdocument,Fixeddocument,上面的代码没有发布任何内容。一旦对flowdocument进行分页并获取页面的可视化表示,可视化视图将引用flowdocument的内容。因此,既不会处理Visual文档,也不会处理flowdocument的内容。 上述代码在执行时会不断从内存中溢出 有人知道如何释放所有这些资源所持有的内存吗 提前感谢。这可能不是解决您问题的方法,但调用GC.Collect多次将释放一些内存。这可能不是解决您问题的方法,但调用GC.Collect多次将释放一些内存。 //Create a
提前感谢。这可能不是解决您问题的方法,但调用GC.Collect多次将释放一些内存。这可能不是解决您问题的方法,但调用GC.Collect多次将释放一些内存。
//Create a User Control with a TextBlock
TextBlock textBlock = new TextBlock();
textBlock.Text = "Helo";
UserControl userCOntrol = new UserControl();
userCOntrol.Content = textBlock;
//Add the UserControl to a Table
table.RowGroups[0].Rows[0].Cells[0].Blocks.Add(new Paragraph(new InlineUIContainer(userCOntrol as UIElement)));
//Add the table to a FlowDocument
FlowDocument flowDocument = new FlowDocument();
flowDocument.Blocks.Add(table);
//Fetch the Visual representation of the page.
DocumentPage page = ((IDocumentPaginatorSource)flowDocument).DocumentPaginator.GetPage(0);
//Extract the Visual from the page and add to a Fixed Page
FixedPage fixedPage = new FixedPage();
ContainerVisual container = new ContainerVisual();
container.Children.Add(page.Visual);
DrawingCanvas canvas= new DrawingCanvas();
canvas.AddVisual(container);
fixedPage.Children.Add(canvas);
//now write the FixedPage to an XPS file
using (XpsDocument xpsDoc = new XpsDocument("c:\\x.xps", FileAccess.ReadWrite))
{
XpsDocumentWriter xpsDw = XpsDocument.CreateXpsDocumentWriter(xpsDoc);
xpsDw.Write(kj);
}