Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Priting in WPF fails to use the user specified printer tray

$
0
0

Hi,

The following code is being used to print some documents. The problem we are having is that no matter what tray we use it always appears to use the default tray. Any help would be greatly appreciated. We were thinking everything hsould be in the UserPrintTicket:

        /// <summary>Print pages.</summary>
        /// <param name="pageViewModels">The page view models.</param>
        private void PrintPages(IEnumerable<IPageViewModel> pageViewModels)
        {
            var printDialog = new PrintDialog();
            bool? print = printDialog.ShowDialog();
            if (print == true)
            {
                var dw = PrintQueue.CreateXpsDocumentWriter(printDialog.PrintQueue);
                var mediaSize = printDialog.PrintQueue.UserPrintTicket.PageMediaSize;
                printDialog.PrintQueue.CurrentJobSettings.Description = "PDAX Document Pages";
                var area = printDialog.PrintQueue.GetPrintCapabilities().PageImageableArea;
                var img = new Image();
                img.Margin = new Thickness(area.OriginWidth, area.OriginHeight, area.OriginWidth, area.OriginHeight);
                var outputSize = new Size(mediaSize.Width.Value, mediaSize.Height.Value);
                var c = dw.CreateVisualsCollator();
                c.BeginBatchWrite();
                foreach (var page in pageViewModels)
                {
                    img.Source = ConvertByteArrayToBitmap(page.Image);
                    img.Measure(outputSize);
                    img.Arrange(new Rect(outputSize));
                    img.UpdateLayout();
                    c.Write(img);
                }

                c.EndBatchWrite();
            }
        }


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>