fixeddocument

Out of memory Exception while printing in WPF

让人想犯罪 __ 提交于 2019-12-04 09:35:01
I was trying to print the set of 70 images in WPF. So I used Fixed document as I saw in many references and tried printing using the below code. private void button1_Click(object sender, RoutedEventArgs e) { PrintDialog d = new PrintDialog(); d.PrintDocument(PrintingDoc().DocumentPaginator, "test"); } private FixedDocument PrintingDoc() { FixedDocument document = new FixedDocument(); Visual viewerControl; string[] Documents = System.IO.Directory.GetFiles("../../U/"); DrawingVisual dv; DrawingContext context ; BitmapImage im ; foreach (string doc in Documents) { dv = new DrawingVisual();

remove page from fixed document?

╄→гoц情女王★ 提交于 2019-12-04 08:58:34
How can I remove a page from a fixedDocument? I add pages like this: // Add page to pageContent PageContent pageContent = new PageContent(); ((IAddChild)pageContent).AddChild(fixedPage); // Add pageContent to wholeDoc fixedDocument.Pages.Add(pageContent); //Add to documentVeiwer documentViewer1.Document = fixedDocument; But there is no 'fixedDocument.Pages.Remove(page)' method! What can I do? Could you try "cloning" the document into a new document and copy / move all pages over to the new document, except for the one(s) you want to remove? Not sure if that would work or not. I know this is an

WPF FixedDocument pagination

风格不统一 提交于 2019-12-04 04:59:34
How do I get FixedDocument to automatically paginate? I have the following code that I can use to put prettified Panel into a DocViewer. The problem occurs when the Panel extends past a single page. Right now, we simply clip. Basically, I want to create a fairly generic way to print what the user is viewing. Is my approach reasonable? public void CreateReport(Panel details) { FixedDocument fixedDoc = new FixedDocument(); PageContent pageContent = new PageContent(); FixedPage fixedPage = new FixedPage(); fixedPage.DataContext = this.DataContext; fixedPage.Margin = new Thickness(10); fixedPage

Saving a FixedDocument to an XPS file causes memory leak

爷,独闯天下 提交于 2019-12-03 17:19:55
问题 I have created a .NET Windows Service which performs certain actions and generates reports. These reports are XPS documents which I save in a certain directory. Being familiar with WPF, the way I have chosen to create the reports is to instantiate a System.Windows.Documents.FixedDocument , adding FixedPage objects with content as required. My problem is that the Service memory usage goes up and up and up over time as it runs. At first, I went through my code rigorously, ensuring all

WPF: FixedDocument in Visual Studio 2008 Designer

做~自己de王妃 提交于 2019-12-03 09:45:44
问题 It's a well-known bug that Visual Studio shows an error when you try to construct a FixedDocument in XAML. For example, the following snippet <DocumentViewer> <FixedDocument> <PageContent> <FixedPage Width="21.0cm" Height="29.7cm"> <TextBlock>Hello World!</TextBlock> </FixedPage> </PageContent> </FixedDocument> </DocumentViewer> compiles and runs perfectly fine, but Visual Studio shows an error in the error list ( Property 'Pages' does not support values of type 'PageContent'. ) This is quite

Saving a FixedDocument to an XPS file causes memory leak

强颜欢笑 提交于 2019-12-03 06:20:47
I have created a .NET Windows Service which performs certain actions and generates reports. These reports are XPS documents which I save in a certain directory. Being familiar with WPF, the way I have chosen to create the reports is to instantiate a System.Windows.Documents.FixedDocument , adding FixedPage objects with content as required. My problem is that the Service memory usage goes up and up and up over time as it runs. At first, I went through my code rigorously, ensuring all disposable objects were disposed, etc, and other obvious memory leak candidates, but still had the problem. I

WPF: FixedDocument in Visual Studio 2008 Designer

拜拜、爱过 提交于 2019-12-03 01:27:08
It's a well-known bug that Visual Studio shows an error when you try to construct a FixedDocument in XAML. For example, the following snippet <DocumentViewer> <FixedDocument> <PageContent> <FixedPage Width="21.0cm" Height="29.7cm"> <TextBlock>Hello World!</TextBlock> </FixedPage> </PageContent> </FixedDocument> </DocumentViewer> compiles and runs perfectly fine, but Visual Studio shows an error in the error list ( Property 'Pages' does not support values of type 'PageContent'. ) This is quite annoying. I'm looking for a solution that allows me to construct my documents in a XAML file in Visual

iTextSharp to generate PDF from WPF FixedDocument

这一生的挚爱 提交于 2019-12-02 21:16:23
I have a simple WPF app that displays and prints some reports with a FixedDocument. How can generate PDF's from that, with a free and open solution, such as iTextSharp? A WPF FixedDocument, also known as an XPS document, is a definite improvement over PDF. It has many capabilities that PDF lacks. In most cases it is better to distribute your document as XPS rather than PDF, but sometimes it is necessary to convert from XPS to PDF, for example if you need to open the document on devices that have only PDF support. Unfortunately most free tools to convert from XPS to PDF, such as CutePDF and

How to convert FlowDocument to FixedDocument using FlowDocument's IDocumentPaginatorSource DocumentPaginator?

非 Y 不嫁゛ 提交于 2019-11-30 14:17:09
问题 I have: DocumentPaginator dp = ((IDocumentPaginatorSource)document).DocumentPaginator; and: FlowDocument document = new FlowDocument(); // create a flow document... How do a convert the FlowDocument to a FixedDocument using the DocumentPaginator? I can't seem to find out how to do this. All sites I looked at use XpsWriter as in: XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(xpsDoc); DocumentPaginator dp = ((IDocumentPaginatorSource)document).DocumentPaginator; writer.Write(dp

How to convert FlowDocument to FixedDocument using FlowDocument's IDocumentPaginatorSource DocumentPaginator?

核能气质少年 提交于 2019-11-30 10:00:27
I have: DocumentPaginator dp = ((IDocumentPaginatorSource)document).DocumentPaginator; and: FlowDocument document = new FlowDocument(); // create a flow document... How do a convert the FlowDocument to a FixedDocument using the DocumentPaginator? I can't seem to find out how to do this. All sites I looked at use XpsWriter as in: XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(xpsDoc); DocumentPaginator dp = ((IDocumentPaginatorSource)document).DocumentPaginator; writer.Write(dp); I could write the XPS and then get back the FixedDocument but there must be a better way? No, there