Print Issue

2 posts, 0 answers
  1. Ram
    Ram avatar
    2 posts
    Member since:
    Mar 2016

    Posted 27 May Link to this post

    Hi Everyone 

     

    What i am trying to do i just want to print the grid.

    here is my code .

    public static void Print(object parameter, List<FilterList> lst, PrinterSettingViewModels Printer)         {             RadGridView grid = (RadGridView)parameter;             RadRichTextBox rtb = new RadRichTextBox() { Height = 0 };             rtb.Name = "RadRichTextBox1";             Grid parent = grid.ParentOfType<Grid>();             if (parent != null && parent.FindName(rtb.Name) == null)             {                 parent.Children.Add(rtb);                 rtb.ApplyTemplate();             }             rtb.Dispatcher.BeginInvoke((Action)(() =>             {                 rtb.Document = CreateDocument(grid, lst);             }));             rtb.Document.MeasureAndArrangeInDefaultSize();             PrintSettings pSettings = new PrintSettings();             PrintDialog printDialog = new PrintDialog();             if (rtb.Document.Sections != null)             {                 if (Printer != null)                 {                     //PrintQueue printQueue = FindPrintQueueByName(Printer.PrinterName);                     pSettings.DocumentName = "My document";                     pSettings.PrintMode = PrintMode.Native;                     pSettings.PrintScaling = Telerik.Windows.Documents.UI.PrintScaling.None;                     pSettings.UseDefaultPrinter = true;                                                    rtb.Print(pSettings);                                    }                 else                 {                     rtb.Print(pSettings);                    // rtb.Print("Document", PrintMode.Native);                 }             }         }

     

    it works great untill i use "pSettings.UseDefaultPrinter = true; ".After using this it always print a blank page. i am not sure about this.can Anyone help me on this.

     

    Thanks

  2. Stefan X1
    Admin
    Stefan X1 avatar
    523 posts

    Posted 01 Jun Link to this post

    Hello Ram,

    The recommended approach for printing RadGridView is to use RadSpreadSheet. The approach is demonstrated in the Print and Print Preview online example or its WPF equivalent.

    I have also attached a sample application in which the UseDefaultPrinter of the PrintSettings is set to true and everything works as expected. Can you please check it out?

    Best Regards,
    Stefan X1
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top