RichTextBox Automatioc Print

15 posts, 0 answers
  1. Harri
    Harri avatar
    12 posts
    Member since:
    Oct 2012

    Posted 22 Oct 2012 Link to this post

    Hi,

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

    thanks, harri.
  2. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 23 Oct 2012 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Harri
    Harri avatar
    12 posts
    Member since:
    Oct 2012

    Posted 24 Oct 2012 Link to this post

    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?

  5. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 24 Oct 2012 Link to this post

    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.

  6. Harri
    Harri avatar
    12 posts
    Member since:
    Oct 2012

    Posted 25 Oct 2012 Link to this post

    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!
  7. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 26 Oct 2012 Link to this post

    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.

  8. Michael
    Michael avatar
    41 posts
    Member since:
    Oct 2010

    Posted 17 Aug 2013 Link to this post

    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.
  9. Anna
    Admin
    Anna avatar
    99 posts

    Posted 20 Aug 2013 Link to this post

    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 >>
  10. Michael
    Michael avatar
    41 posts
    Member since:
    Oct 2010

    Posted 20 Aug 2013 Link to this post

    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.

  11. Petya
    Admin
    Petya avatar
    975 posts

    Posted 22 Aug 2013 Link to this post

    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 >>
  12. Jorge
    Jorge avatar
    6 posts
    Member since:
    Apr 2013

    Posted 25 Sep 2013 Link to this post

    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

  13. Petya
    Admin
    Petya avatar
    975 posts

    Posted 27 Sep 2013 Link to this post

    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 >>
  14. Michael
    Michael avatar
    41 posts
    Member since:
    Oct 2010

    Posted 09 Jul 2014 in reply to Petya Link to this post

    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
  15. Jorge
    Jorge avatar
    6 posts
    Member since:
    Apr 2013

    Posted 10 Jul 2014 Link to this post

    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);
                    }
                }

  16. Petya
    Admin
    Petya avatar
    975 posts

    Posted 10 Jul 2014 Link to this post

    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.
     
Back to Top
UI for WPF is Visual Studio 2017 Ready