Пример #1
0
        private static IDocument GetDocument(DataView data, IEnumerable <PrintColumnInfo> columnsInfo, string title)
        {
            var pageSize = new Size(8.5 * 96, 11 * 96);
            Func <int, IBlankPage> pageFactoryMethod = pageNum => new BlankPageBase
            {
                PageSize = pageSize,
            };
            var blankPageSource = new RelayedBlankPageSource(pageFactoryMethod);
            var docFormatter    = new SimpleTitledTableDataFormatter(data, columnsInfo, title);

            return(new SimpleDocument(blankPageSource, docFormatter));
        }
        private void GoClick(object sender, RoutedEventArgs e)
        {
            var blockFormatterFactory = new BlockFormattersFactory();
            var pm = new PrintManager();

            var formatter = new SimpleFlowDocumentDataFormatter();

            for (int i = 0; i < _count; i++)
            {
                string headerText = String.Format("Page {0} title", i);
                formatter.AppendBlocks(blockFormatterFactory.HeaderFromNewPage(headerText));
            }

            Func <int, IBlankPage> pageFactoryMethod = pageNum => new SimpleBlankPage
            {
                Header = "Header/Footer printing sample",
                Footer = String.Format("Page number: {0}", pageNum + 1)
            };
            var blankPageSource = new RelayedBlankPageSource(pageFactoryMethod);

            var doc = new SimpleDocument(blankPageSource, formatter);

            pm.PrintPreview(doc);
        }