Example #1
0
        /// <summary>
        /// Creates a DocumentPaginatorWrapper from TextEditor text to print.
        /// </summary>
        static DocumentPaginatorWrapper CreateDocumentPaginatorToPrint(TextEditor textEditor)
        {
            // this baby adds headers and footers
            IDocumentPaginatorSource dps = CreateFlowDocumentToPrint(textEditor);

            DocumentPaginatorWrapper dpw = new DocumentPaginatorWrapper(dps.DocumentPaginator, mPageSettings, mPrintTicket, textEditor.FontFamily);

            dpw.Title = mDocumentTitle;

            return(dpw);
        }
        /// <summary>
        /// Loads the specified DocumentPaginatorWrapper document for print preview.
        /// </summary>
        public void LoadDocument(DocumentPaginatorWrapper document)
        {
            mDocument = document;

              string temp = System.IO.Path.GetTempFileName();

              if (File.Exists(temp) == true)
            File.Delete(temp);

              XpsDocument xpsDoc = new XpsDocument(temp, FileAccess.ReadWrite);

              XpsDocumentWriter xpsWriter = XpsDocument.CreateXpsDocumentWriter(xpsDoc);

              xpsWriter.Write(document);

              documentViewer.Document = xpsDoc.GetFixedDocumentSequence();

              xpsDoc.Close();
        }
        /// <summary>
        /// Loads the specified DocumentPaginatorWrapper document for print preview.
        /// </summary>
        public void LoadDocument(DocumentPaginatorWrapper document)
        {
            mDocument = document;

            string temp = System.IO.Path.GetTempFileName();

            if (File.Exists(temp) == true)
            {
                File.Delete(temp);
            }

            XpsDocument xpsDoc = new XpsDocument(temp, FileAccess.ReadWrite);

            XpsDocumentWriter xpsWriter = XpsDocument.CreateXpsDocumentWriter(xpsDoc);

            xpsWriter.Write(document);

            documentViewer.Document = xpsDoc.GetFixedDocumentSequence();

            xpsDoc.Close();
        }