Exemple #1
0
        public static int SaveAsXps(FlowDocument doc, string fileName, Size printableArea)
        {
            doc.ColumnWidth = printableArea.Width;
            using (Package container = Package.Open(fileName, FileMode.Create))
            {
                using (XpsDocument xpsDoc = new XpsDocument(container, CompressionOption.Maximum))
                {
                    XpsSerializationManager rsm       = new XpsSerializationManager(new XpsPackagingPolicy(xpsDoc), false);
                    DocumentPaginator       paginator = ((IDocumentPaginatorSource)doc).DocumentPaginator;
                    paginator.ComputePageCount();

                    DocumentPaginator newPaginator = new DocumentPaginatorWrapper(
                        paginator,
                        printableArea, new Size(8, 8));

                    rsm.SaveAsXaml(paginator);
                }
            }

            return(0);
        }
Exemple #2
0
        public static int SaveAsXps(FlowDocument doc, string fileName, Size printableArea)
        {
            doc.ColumnWidth = printableArea.Width;
            using (Package container = Package.Open(fileName, FileMode.Create))
            {
                using (XpsDocument xpsDoc = new XpsDocument(container, CompressionOption.Maximum))
                {
                    XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(xpsDoc), false);
                    DocumentPaginator paginator = ((IDocumentPaginatorSource)doc).DocumentPaginator;
                    paginator.ComputePageCount();

                    DocumentPaginator newPaginator = new DocumentPaginatorWrapper(
                        paginator,
                        printableArea, new Size(8, 8));

                    rsm.SaveAsXaml(paginator);
                }
            }

            return 0;
        }