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

Silent print without using the toolbar

4 Answers 290 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
Rouven
Top achievements
Rank 1
Rouven asked on 11 Jul 2013, 08:06 AM
Hello Telerik-Team,
im using the 2013 Q1 release.
Is it possible to print, without using the toolbar ?

I would like to print a document from the code behind.

Thanks
Rouven

4 Answers, 1 is accepted

Sort by
0
Accepted
Wenjie
Top achievements
Rank 1
answered on 11 Jul 2013, 04:48 PM
Default printer only.

System.IO.MemoryStream mstreamPdfToPrint;
private void btnLoadPdf_Click(object sender, RoutedEventArgs e)
{
    e.Handled = true;
 
    string strPdfFilenName = "";
    var dlg = new Microsoft.Win32.OpenFileDialog();
    dlg.Filter = "PDF files (*.pdf)|*.pdf";
 
    if (dlg.ShowDialog().Value)
    {
        strPdfFilenName = dlg.FileName;
 
        System.IO.FileStream fstreamLoaded = new System.IO.FileStream(strPdfFilenName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
 
        mstreamPdfToPrint = new System.IO.MemoryStream();
 
        fstreamLoaded.CopyTo(mstreamPdfToPrint);
 
    }
 
}
 
private void btnPrintPDF_Click(object sender, RoutedEventArgs e)
{
    e.Handled = true;
    Telerik.Windows.Controls.RadPdfViewer rdPdfViewerPrint = new Telerik.Windows.Controls.RadPdfViewer();
 
    Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider prvdPdfPrint = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider(mstreamPdfToPrint, Telerik.Windows.Documents.Fixed.FormatProviders.FormatProviderSettings.ReadAllAtOnce);
    rdPdfViewerPrint.Document = prvdPdfPrint.Import();
    rdPdfViewerPrint.Print(new Telerik.Windows.Documents.Fixed.Print.PrintSettings(@"Document1", true));
 
}
0
Rouven
Top achievements
Rank 1
answered on 12 Jul 2013, 05:26 AM
Thank you Wenjie, this works perfect.
0
Klaus
Top achievements
Rank 1
answered on 06 Nov 2013, 02:25 PM
We have a Silverlight application running with elevated rights, do you have a solution where we can load and print a PDF document silently?
0
Petya
Telerik team
answered on 08 Nov 2013, 02:41 PM
Hello Klaus,

RadPdfViewer for Silverlight allows you to print to the default printer in Silverlight OOB applications with elevated trust. What you should do is set the UseDefaultPrinter in the PrintSettings property to true. Please refer to the documentation of the printing feature here

I hope this helps!

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 >>
Tags
PDFViewer
Asked by
Rouven
Top achievements
Rank 1
Answers by
Wenjie
Top achievements
Rank 1
Rouven
Top achievements
Rank 1
Klaus
Top achievements
Rank 1
Petya
Telerik team
Share this question
or