简体   繁体   中英

Can I print an SSRS Report using PrintDocument?

I have an SSRS report that I need to print from my windows form application using VS 2008 (C#). I want to print this report using PrintDocument. Is there anyway to do this? Here is what I have:

private void Printing(string pname)
{
    PrintDocument printDoc = new PrintDocument();
    if (pname.Length > 0)
        printDoc.PrinterSettings.PrinterName = pname;

    PageSettings ps = new PageSettings();
    PaperSize pz = new PaperSize();

    pz.Height = 650;
    pz.Width = 400;
    ps.PaperSize = pz;

    printDoc.DefaultPageSettings = ps;
    printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
    printDoc.Print();
}


private void printDoc_PrintPage(Object sender, PrintPageEventArgs e)
{    

}

I just don't know how to attach the report name to the PrintDocument.

You will need to use the ReportExecution2005.ReportExecutionService and call the Render method with the format set to "IMAGE" and device info data set similar to:

<DeviceInfo>
    <OutputFormat>TIFF</OutputFormat>
</DeviceInfo>

The device info can be used for images to control dpi specific parameters used in print controls.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM