var package = Package.Open(dlg.FileName, FileMode.Create); var xpsDoc = new XpsDocument(package, CompressionOption.Normal); XpsDocumentWriter xpsWriter = XpsDocument.CreateXpsDocumentWriter(xpsDoc);
// xps documents are built using fixed document sequences var fixedDocSeq = new FixedDocumentSequence(); var docRef = new DocumentReference(); docRef.BeginInit(); docRef.SetDocument(reportViewerControl.GetFixedDocument()); docRef.EndInit(); ((IAddChild)fixedDocSeq).AddChild(docRef);
// write out our fixed document to xps xpsWriter.Write(fixedDocSeq.DocumentPaginator);
xpsDoc.Close(); package.Close(); |