public PreviewWindow(CustomDocumentPaginator documentPaginator) { InitializeComponent(); //xps stream = new MemoryStream(); Package package = Package.Open(stream, FileMode.Create, FileAccess.ReadWrite); var uri = new Uri(@"memorystream://myXps.xps"); //already in packagestore, so remove if (PackageStore.GetPackage(uri) != null) { PackageStore.RemovePackage(uri); } PackageStore.AddPackage(uri, package); var xpsDoc = new XpsDocument(package); xpsDoc.Uri = uri; XpsDocument.CreateXpsDocumentWriter(xpsDoc).Write(documentPaginator); FixedDocumentSequence fds = xpsDoc.GetFixedDocumentSequence(); dv1.Document = (IDocumentPaginatorSource)fds; }
private void prepareDocument() { //create a flowdocument FlowDocument flowDocument = new FlowDocument(); //add content for (int x = 0; x < listFilesText.Count; x++) { //add name Paragraph pFileName = new Paragraph(); pFileName.Inlines.Add(listFilesText[x].FileName); Section sFileName = new Section(pFileName); sFileName.Background = new SolidColorBrush(Colors.Black); sFileName.Foreground = new SolidColorBrush(Colors.White); flowDocument.Blocks.Add(sFileName); //add text Paragraph pText = new Paragraph(); pText.Inlines.Add(listFilesText[x].Text); Section sText = new Section(pText); flowDocument.Blocks.Add(sText); } //add to paginator String headerText = userCode + " | " + StudNo; documentPaginator = new CustomDocumentPaginator(((IDocumentPaginatorSource)flowDocument).DocumentPaginator, new Size(793.5987, 1122.3987), new Size(96, 96), headerText); }