Question

I am developing a Winforms app, following this tutorial to make a report out of XML file. Now I need to print it on a specific type of printer 'BIXOLON' and specific type of paper, I need to include this information then perform a print.

I tried to copy and paste this code from msdn, but I got an error:

An error occurred during local report processing.

on that line

    private void Export(LocalReport report)
    {
        string deviceInfo =
          @"<DeviceInfo>
            <OutputFormat>EMF</OutputFormat>
            <PageWidth>8.5in</PageWidth>
            <PageHeight>11in</PageHeight>
            <MarginTop>0</MarginTop>
            <MarginLeft>0</MarginLeft>
            <MarginRight>0</MarginRight>
            <MarginBottom>0</MarginBottom>
        </DeviceInfo>";
        Warning[] warnings;
        m_streams = new List<Stream>();
       /*>>>>>*/ report.Render("Image", deviceInfo, CreateStream, out warnings);
    }

I don't know how to print directly to the printer

Was it helpful?

Solution

The code from MSDN use PrintDocument to print report. Simply set this property to use a specific printer:

printDoc.PrinterSettings.PrinterName = "NameOfYourPrinter"

If you get an error on Report.Render maybe there is a problem in your rdlc file. Can you view it in a ReportViewer without error?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top