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

RichTextBox Automatioc Print

14 Answers 110 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Harri
Top achievements
Rank 1
Harri asked on 22 Oct 2012, 02:01 PM
Hi,

I use RichTextBox print method. but i want to print without user interaction. can I cancel PrintDialog pop up window?

thanks, harri.

14 Answers, 1 is accepted

Sort by
0
Kammen
Telerik team
answered on 23 Oct 2012, 04:47 PM
Hi Harri,

You can use the Print method's overload that takes PrintSettigns. In this settings you can set the UseDefaultPrinter property to true. If you do so, the default printer will be used in order to print the document and no dialog will be shown.

Hope this answer your question.

Regards,
Kammen
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Harri
Top achievements
Rank 1
answered on 24 Oct 2012, 08:08 AM
First, thank you for your reply.

I cant find UseDefaultPrinter property in PrintSettings object. PrintSettings looks like this:

#region

 

 

Assembly Telerik.Windows.Documents.dll, v4.0.30319

 

#endregion

using

System;

 

using

Telerik.Windows.Documents.FormatProviders.Html;

 

namespace

Telerik.Windows.Documents.UI

public class PrintSettings

{

public PrintSettings();

public string DocumentName { get; set; }

 public HtmlExportSettings HtmlPrintExportSettings { get; set; }

 public PrintMode PrintMode { get; set; }

public PrintScaling PrintScaling { get; set; }

 }

}

Does it exist already in  Q3 2011 SP1 version?

0
Iva Toteva
Telerik team
answered on 24 Oct 2012, 10:11 AM
Hello Harri,

The option to print silently using the default printer was implemented in 2012 Q2 SP1 (2012.2 725). It will not be possible to use this functionality in the previous versions of the control.

Greetings,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Harri
Top achievements
Rank 1
answered on 25 Oct 2012, 07:36 AM
I am considering to upgrade version.
 
Another question to be absolutely sure:
Will I have control the PrintDialog itself? Is it possible to change its properties like PrinterName, PrintTicket.... ?

thanks!
0
Kammen
Telerik team
answered on 26 Oct 2012, 10:09 AM
Hello Harri,

You have control only on the DocumentName property of the print dialog. The only change in PdfSettings compared to older versions is the UseDefaultPrinter that will allow you to print silently. 

All the best,
Kammen
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Michael
Top achievements
Rank 1
answered on 17 Aug 2013, 08:16 PM
How can you print to a non-default printer?  I want to be able to define the printer on the backend and have user print to this printer without any prompt.
0
Anna
Telerik team
answered on 20 Aug 2013, 02:20 PM
Hi Michael,

Unfortunately it is not possible to silently print a document to a printer other than the default one through RadRichTextBox.

Regards,
Anna
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Michael
Top achievements
Rank 1
answered on 20 Aug 2013, 03:51 PM
Hi Anna,

Thank you for your reply.  While I was waiting for the answer, I looked into your source code.  This feature is quite simple to implement.  Maybe you can include it in the future build.

I've modified PrintSettings class and added properties where user can specify if the want to use a specific printer and its name:

public bool UseSpecifiedPrinter { get; set; }

public string PrinterName { get; set; }


Then I've modified the Print(PrintSettings settings) method of DocumentPrintPresenter class as follows:

if (settings.UseSpecifiedPrinter)

{

     printDialog.PrintQueue = new PrintQueue(new PrintServer(), settings.PrinterName);

}

else

{

     if (printDialog.ShowDialog() != true)

     {

         return;

     }

}

Basically, instead of showing dialog of PrintDialog object, you can assign printer name through PrintQueue.

Now when user clicks on Print button, instead of default Command, I implement Click event.  I define PrintSettings class with the printer I want and pass it to RadRichTextBox.Print method.

Hope this helps and you can include something similar in the future build.

0
Petya
Telerik team
answered on 22 Aug 2013, 08:03 AM
Hello Michael,

Thank you for getting back to us!

We will consider implementing this feature for one of our feature releases. However, at this point the task is with relatively low priority and I cannot tell when it might be available.

Let us know if you have additional comments or other questions.

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Jorge
Top achievements
Rank 2
answered on 25 Sep 2013, 03:24 PM
Hi Anna, 

For us this would be a great feature to have maybe for SIlverlight is more complicated, but for WPF would be awsome !

And for a project we currently have this is a must!.


BR

Jorge

0
Petya
Telerik team
answered on 27 Sep 2013, 04:09 PM
Hello Jorge,

I am glad to inform you that with the upcoming in a few weeks Q3 2013 release functionality allowing you to print silently to a printer which is not the default from RadRichTextBox for WPF will be available. We will make sure to update the respective documentation and create demos showing the functionality as well.

Let us know if you have any other feedback.

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Michael
Top achievements
Rank 1
answered on 09 Jul 2014, 07:41 PM
Hello,

In your last reply, you said that you have implemented the feature where I can specify the printer name instead of using the default printer.  Can you please give example how to use it?

Thanks
0
Jorge
Top achievements
Rank 2
answered on 10 Jul 2014, 12:46 PM
we do something like this:

RadDocument document = this.previewRadRichTextBox.Document;
            if (document != null)
            {
                PrintDialog printDialog = new PrintDialog();
                Core.Windows.Services.PrinterInformation selectedPrinter = (Core.Windows.Services.PrinterInformation)PrintersComboBox.SelectedItem;
                PrintQueue printQueue = this.FindPrintQueueByName(selectedPrinter.PrinterName);

                if (printQueue == null)
                    printQueue = printDialog.PrintQueue;

                if (Collate_ComboBox.SelectedIndex == 0)
                    printQueue.DefaultPrintTicket.Collation = System.Printing.Collation.Collated;
                else
                    printQueue.DefaultPrintTicket.Collation = System.Printing.Collation.Uncollated;

                if (_mainLayout.PackageHelper.PackageConfiguration.IsPageSizeLetter)
                {
                    printQueue.DefaultPrintTicket.PageMediaSize = new PageMediaSize(PageMediaSizeName.NorthAmericaLetter, 850, 1056);
                    printQueue.CurrentJobSettings.CurrentPrintTicket.PageMediaSize = new PageMediaSize(PageMediaSizeName.NorthAmericaLetter, 850, 1056);
                }
                else
                {
                    PageMediaSize pms = new PageMediaSize(PageMediaSizeName.NorthAmericaLegal, 850, 1275);
                    printQueue.DefaultPrintTicket.PageMediaSize = pms;
                    printQueue.UserPrintTicket.PageMediaSize = pms;
                    printQueue.CurrentJobSettings.CurrentPrintTicket.PageMediaSize = pms;
                }

                printQueue.CurrentJobSettings.CurrentPrintTicket.CopyCount = (int)NumberOfCopies.Value;

                printDialog.PrintQueue = printQueue;
                printDialog.PageRangeSelection = PageRangeSelection.UserPages;
                printDialog.PageRange = new PageRange((int)FirstPageToPrint_RadNumericUpDown.Value, (int)LastPageToPrint_RadNumericUpDown.Value);
                printDialog.PrintTicket.CopyCount = (int)NumberOfCopies.Value;

                for (int copy = 1; copy <= (int)NumberOfCopies.Value; copy++)
                {
                        PrintSettings ps = new PrintSettings();
                        ps.DocumentName = PackageHelper._packageName;
                        ps.UseDefaultPrinter = false;
                        //PrintMode pm = new PrintMode();

                        this.previewRadRichTextBox.Print(printDialog, ps);
                }
            }

0
Petya
Telerik team
answered on 10 Jul 2014, 12:57 PM
Hello,

@Jorge Thank you for helping the community out, we appreciate it. 

@Michael Other than Jorge's example, you could check our SDK samples. The CustomizePrinting project is also accessible directly from the repository here.

Regards,
Petya
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
RichTextBox
Asked by
Harri
Top achievements
Rank 1
Answers by
Kammen
Telerik team
Harri
Top achievements
Rank 1
Iva Toteva
Telerik team
Michael
Top achievements
Rank 1
Anna
Telerik team
Petya
Telerik team
Jorge
Top achievements
Rank 2
Share this question
or