Esempio n. 1
0
        public PrintPreviewWindow(FlowDocument flowDoc, Paragraph generalContent)
        {
            InitializeComponent();
            num  = 816.0;
            num2 = 1056.0;
            docViewer.FitToWidth();
            Thickness thickness          = new Thickness(1);
            Thickness textMargin         = new Thickness(thickness.Left * 96.0, thickness.Top * 96.0, thickness.Right * 96.0, thickness.Bottom * 96.0);
            Thickness headerFooterMargin = new Thickness(19.200000000000003);

            System.IO.MemoryStream s = new System.IO.MemoryStream();
            TextRange source         = new TextRange(flowDoc.ContentStart, flowDoc.ContentEnd);

            source.Save(s, DataFormats.Xaml);
            FlowDocument copy = new FlowDocument();
            TextRange    dest = new TextRange(copy.ContentStart, copy.ContentEnd);

            dest.Load(s, DataFormats.Xaml);
            copy.PagePadding = new Thickness(0.0);
            copy.ColumnWidth = double.PositiveInfinity;
            copy.Blocks.InsertBefore(copy.Blocks.FirstBlock, generalContent);

            IList <PageRange> ranges = null;

            this.documentPaginator = new CommonDocumentPaginator(((IDocumentPaginatorSource)copy).DocumentPaginator, new Size(num, num2), textMargin, headerFooterMargin, ranges, true);
            if (!this.documentPaginator.IsPageCountValid)
            {
                documentPaginator.ComputePageCountCompleted += new AsyncCompletedEventHandler(this.documentPaginator_ComputePageCountCompleted);
                documentPaginator.ComputePageCountAsync();
                return;
            }
            CreateDocument(documentPaginator);
            //XpsDocument xpsDoc = LoadAsXPS(new CommonDocumentPaginator(((IDocumentPaginatorSource)flowDoc).DocumentPaginator, new Size(595, 842), new Size(48, 48)));
            //docViewer.Document = xpsDoc.GetFixedDocumentSequence();
        }
Esempio n. 2
0
 /// <summary>
 /// Compute page count async.
 /// </summary>
 /// <param name="userState">The user state.</param>
 public override void ComputePageCountAsync(object userState)
 {
     flowDocPaginator.ComputePageCountAsync(userState);
 }