/// <summary> /// Convert a FixedDocument to an XPS file. /// </summary> /// <param name="fixedDoc">The FixedDocument to convert.</param> /// <param name="outputStream">The output stream.</param> public static void ConvertToXps(FixedDocument fixedDoc, Stream outputStream) { var package = Package.Open(outputStream, 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(fixedDoc); docRef.EndInit(); ((IAddChild)fixedDocSeq).AddChild(docRef); // write out our fixed document to xps xpsWriter.Write(fixedDocSeq.DocumentPaginator); xpsDoc.Close(); package.Close(); }
private FixedDocumentSequence CreateFixedDocumentSequence(IEnumerable<IEnumerable<string>> projects, Size areaExtent, Size areaOrigin, bool fixedStrokeThickness, DiagramTable table) { var fixedDocumentSeq = new FixedDocumentSequence() { Name = "diagrams" }; foreach (var diagrams in projects) { var fixedDocument = CreateFixedDocument(diagrams, areaExtent, areaOrigin, fixedStrokeThickness, table); var documentRef = new DocumentReference(); documentRef.BeginInit(); documentRef.SetDocument(fixedDocument); documentRef.EndInit(); (fixedDocumentSeq as IAddChild).AddChild(documentRef); } return fixedDocumentSeq; }