Silent print without using the toolbar

5 posts, 1 answers
  1. Rouven
    Rouven avatar
    9 posts
    Member since:
    May 2011

    Posted 11 Jul 2013 Link to this post

    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
  2. Answer
    Wenjie
    Wenjie avatar
    35 posts
    Member since:
    Mar 2013

    Posted 11 Jul 2013 Link to this post

    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));
     
    }
  3. UI for WPF is Visual Studio 2017 Ready
  4. Rouven
    Rouven avatar
    9 posts
    Member since:
    May 2011

    Posted 12 Jul 2013 Link to this post

    Thank you Wenjie, this works perfect.
  5. Klaus
    Klaus avatar
    1 posts
    Member since:
    Nov 2013

    Posted 06 Nov 2013 Link to this post

    We have a Silverlight application running with elevated rights, do you have a solution where we can load and print a PDF document silently?
  6. Petya
    Admin
    Petya avatar
    975 posts

    Posted 08 Nov 2013 Link to this post

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