This is a migrated thread and some comments may be shown as answers.

Print Issue

1 Answer 24 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ram
Top achievements
Rank 1
Ram asked on 27 May 2016, 01:02 PM

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

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 01 Jun 2016, 12:18 PM
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.
Tags
General Discussion
Asked by
Ram
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or