Ejemplo n.º 1
0
 public static void SaveFlowAsXpsInFile(FlowDocument flowDocument)
 {
     using (Package container = Package.Open("journal.xps", FileMode.Create))
     {
         using (XpsDocument xpsDoc = new XpsDocument(container, CompressionOption.Maximum))
         {
             XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(xpsDoc), false);
             DocumentPaginator paginator = ((IDocumentPaginatorSource)flowDocument).DocumentPaginator;
             paginator = new DocumentPaginatorWrapper(paginator, new Size(768, 676), new Size(48, 48));
             rsm.SaveAsXaml(paginator);
         }
     }
 }
Ejemplo n.º 2
0
 public static XpsDocument CreateXpsDocumentFromString(string xamlFlowDoc)
 {
     object doc;
     doc = XamlReader.Parse(xamlFlowDoc);
     MemoryStream ms = new MemoryStream();
     Package pkg = Package.Open(ms, FileMode.Create, FileAccess.ReadWrite);
     string pack = "pack://report.xps";
     PackageStore.RemovePackage(new Uri(pack));
     PackageStore.AddPackage(new Uri(pack), pkg);
     XpsDocument xpsDoc = new XpsDocument(pkg, CompressionOption.NotCompressed, pack);
     XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(xpsDoc), false);
     DocumentPaginator paginator = ((IDocumentPaginatorSource)doc).DocumentPaginator;
     //paginator = new PimpedPaginator(paginator,);
     paginator = new DocumentPaginatorWrapper(paginator, new Size(768, 676), new Size(48, 48));
     rsm.SaveAsXaml(paginator);
     return xpsDoc;
 }
Ejemplo n.º 3
0
 public static XpsDocument SaveFlowAsXpsInMemory(FlowDocument flowDocument)
 {
     MemoryStream ms = new MemoryStream();
     Package container = Package.Open(ms, FileMode.Create, FileAccess.ReadWrite);
     Uri documentUri = new Uri("pack://InMemoryDocument.xps");
     PackageStore.AddPackage(documentUri, container);
     XpsDocument xpsDoc = new XpsDocument(container, CompressionOption.Fast, documentUri.AbsoluteUri);
     XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(xpsDoc), false);
     DocumentPaginator paginator = ((IDocumentPaginatorSource)flowDocument).DocumentPaginator;
     paginator = new DocumentPaginatorWrapper(paginator, new Size(768, 676), new Size(48, 48));
     rsm.SaveAsXaml(paginator);
     xpsDoc.Close();
     container.Close();
     return xpsDoc;
 }