Beispiel #1
0
        /// <summary>
        /// Saves a flow document as an XPS file
        /// </summary>
        /// <param name="document">The document to be sabed.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="pageWidth">Width of the page.</param>
        /// <param name="pageHeight">Height of the page.</param>
        public static void SaveAsXps(this FlowDocument document, string fileName, double pageWidth = 816, double pageHeight = 1056)
        {
            if (!fileName.ToLower().EndsWith(".xps"))
                fileName += ".xps";

            using (var container = Package.Open(fileName, FileMode.Create))
            using (var xpsDoc = new XpsDocument(container, CompressionOption.Maximum))
            {
                var rsm = new XpsSerializationManager(new XpsPackagingPolicy(xpsDoc), false);
                var paginator = new DocumentPaginatorEx(document, new Size(pageWidth, pageHeight), new PageRange());
                rsm.SaveAsXaml(paginator);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Saves a flow document as an XPS file
        /// </summary>
        /// <param name="document">The document to be sabed.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="pageWidth">Width of the page.</param>
        /// <param name="pageHeight">Height of the page.</param>
        public static void SaveAsXps(this FlowDocument document, string fileName, double pageWidth = 816, double pageHeight = 1056)
        {
            if (!fileName.ToLower().EndsWith(".xps"))
            {
                fileName += ".xps";
            }

            using var container = Package.Open(fileName, FileMode.Create);
            using var xpsDoc    = new XpsDocument(container, CompressionOption.Maximum);
            var rsm       = new XpsSerializationManager(new XpsPackagingPolicy(xpsDoc), false);
            var paginator = new DocumentPaginatorEx(document, new Size(pageWidth, pageHeight), new PageRange());

            rsm.SaveAsXaml(paginator);
        }