14 Answers, 1 is accepted
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.
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?
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.
Iva Toteva
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Another question to be absolutely sure:
Will I have control the PrintDialog itself? Is it possible to change its properties like PrinterName, PrintTicket.... ?
thanks!
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.
Unfortunately it is not possible to silently print a document to a printer other than the default one through RadRichTextBox.
Regards,
Anna
Telerik
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 >>
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.
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
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 >>
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
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
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 >>
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
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);
}
}
@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