| |
Data Dynamics Reports Support
Started by dobbo at 07-13-2007 6:31 AM. Topic has 13 replies.
 
 
 
|
|
Sort Posts:
|
|
|
|
07-13-2007, 6:31 AM
|
dobbo
Joined on 07-10-2007
Posts 9
|
Printing report programmatically
|
|
|
|
|
I am struggling to find how to print a report programmatically without going through the Report Preview control.
Can this be done as we have a task to be able to print reports from a back end service process?
|
|
|
|
|
Report
|
|
|
|
07-13-2007, 12:53 PM
|
Jon Smith - DD
Joined on 02-21-2007
Raleigh, NC
Posts 958

|
Re: Printing report programmatically
|
|
|
|
|
Basically, you need to create a ReportDefinition object and load the rdlx report file. Create a ReportRuntime object using the ReportDefinition object as a parameter.
You'll need to make sure your project references both the DataDynamics.Reports and DataDynamics.Reports.Rendering.Graphics assemblies.
Use a PrintDocumentRenderingExtension to render the report to, then call the Print method off of the rendering extension's Document object.
C#:
ReportDefinition rd = new ReportDefinition(new FileInfo(Application.StartupPath + "\\..\\..\\Report1.rdlx")); ReportRuntime rt = new ReportRuntime(rd);
PrintDocumentRenderingExtension renderExt = new PrintDocumentRenderingExtension(); FileStreamProvider fsp = new FileStreamProvider(new DirectoryInfo(Application.StartupPath), "doc"); NameValueCollection nvc = new NameValueCollection(); nvc.Add("PrintLayoutMode", "OneLogicalPageOnSinglePhysicalPage");
rt.Render(renderExt, fsp, nvc);
renderExt.Document.Print();
This code assumes the following using directives have been added to the top of the file:
using System.IO; using DataDynamics.Reports; using DataDynamics.Reports.Rendering.IO; using DataDynamics.Reports.Rendering.Graphics;
-Jon
|
|
|
|
|
Report
|
|
|
|
07-17-2007, 7:42 AM
|
dobbo
Joined on 07-10-2007
Posts 9
|
Re: Printing report programmatically
|
|
|
|
|
Thanks Jon, this works a treat.
One further question, when printing my report needs to print in landscape but all my output comes out in portrait. Is there a way I can change this?
TIA
John
|
|
|
|
|
Report
|
|
|
|
07-17-2007, 10:58 AM
|
Jon Smith - DD
Joined on 02-21-2007
Raleigh, NC
Posts 958

|
Re: Printing report programmatically
|
|
|
|
|
John,
This is currently a known issue with a tracking number of CR# 25032. The Report Definition Language has no concept of page orientation, however, you can currently mimic Landscape orientation by setting the page width to 11" and page height to 8.5". This is one of our highest priority tasks and should be fixed in the next release.
Thanks, Jon
|
|
|
|
|
Report
|
|
|
|
07-24-2007, 12:13 AM
|
Jon Smith - DD
Joined on 02-21-2007
Raleigh, NC
Posts 958

|
Re: Printing report programmatically
|
|
|
|
|
John,
We have added a fix to this change request in our internal code base. This issue will definitely be resolved in the next release.
If you have any more question, feel free to ask.
Thanks, -Jon
|
|
|
|
|
Report
|
|
|
|
07-24-2007, 5:22 AM
|
dobbo
Joined on 07-10-2007
Posts 9
|
Re: Printing report programmatically
|
|
|
|
|
|
|
|
03-02-2008, 8:01 PM
|
rolandg
Joined on 01-11-2008
Posts 5
|
Re: Printing report programmatically
|
|
|
|
|
Jon -
In my situation I have to print any number of RDLs sequentially and present a Print Dialog box to the user the before the print. Would you recommend that I follow the code snippet you posted above? And set the forceDataRefresh parameter to True?
Thanks,
Roland
|
|
|
|
|
Report
|
|
|
|
03-02-2008, 10:06 PM
|
Jon Smith - DD
Joined on 02-21-2007
Raleigh, NC
Posts 958

|
Re: Printing report programmatically
Attachment: Printing.zip
|
|
|
|
|
Roland,
I've created a small sample which demonstrates a method of printing similar to your requirements. This sample was created with the latest build 1.0.342.0 which is available here:
http://www.datadynamics.com/forums/77/ShowForum.aspx
If you have any more questions, feel free to ask.
Thanks, Jon
|
|
|
|
|
Report
|
|
|
|
02-09-2009, 3:00 PM
|
paulywally
Joined on 01-30-2009
Posts 40
|
Re: Printing report programmatically
|
|
|
|
|
Hi,
I am using WPF. How would I go about using the System.Windows.Controls.PrintDialog as opposed to the old System.Windows.Forms.PrintDialog? In the old dialog, you set renderer.Document.PrinterSettings = printDialog.PrinterSettings, but the new dialog does not appear to have PrinterSettings, only a PrintQueue. Maybe I am missing something obvious. Any help would be appreciated.
Thanks in advance,
Pauly
|
|
|
|
|
Report
|
|
|
|
05-21-2009, 11:25 AM
|
paulywally
Joined on 01-30-2009
Posts 40
|
|
|
Jon,
I tried your printing.zip example and it works fine for portrait reports, but does not work for landscape. I changed one of the test reports to landscape and it still prints portrait. The code settings["Orientation"] = "Landscape" seems to do nothing.
I am using version 1.5.1052.0. I attached the changed report.
Please help. Thanks,
Pauly
|
|
|
|
|
Report
|
|
|
|
05-27-2009, 2:47 PM
|
SandeepS
Joined on 12-11-2008
Posts 269

|
Re: Printing report programmatically
|
|
|
|
|
Hello,
We are working on this issue and will get back to you ASAP with our findings and observations.
Regards,
Sandeep
|
|
|
|
|
Report
|
|
|
|
05-28-2009, 12:54 PM
|
SandeepS
Joined on 12-11-2008
Posts 269

|
|
|
Hello,
Please find attached a sample application that shows how you can print a report programatically in Landscape mode.
Regards,
Sandeep
|
|
|
|
|
Report
|
|
|
|
08-05-2010, 4:18 PM
|
paulywally
Joined on 01-30-2009
Posts 40
|
Re: Printing report programmatically
|
|
|
|
|
FYI,
This doesn't work with master reports. The page width/height and PaperOrientation is not set from the master. You have to manually open the master to get this info.
Code is below for others having problems.
Pauly
// orientation is not set if it has a master!
ReportDefinition orientationDefinition;
if (reportDefinition.Report.MasterReport != null && reportDefinition.Report.MasterReport != "")
orientationDefinition = new ReportDefinition(new FileInfo(_reportPath + reportDefinition.Report.MasterReport));
else
orientationDefinition = reportDefinition;
// get the default rendering settings
NameValueCollection settings = ((IConfigurable)_renderer).GetSupportedSettings().GetSettings();
settings["PrinterName"] = printerSettings.PrinterName;
// get orientation from report
if (orientationDefinition.Report.PaperOrientation == PaperOrientation.Landscape)
settings["Orientation"] = "Landscape";
else
settings["Orientation"] = "Portrait";
// render
reportRuntime.Render(_renderer, null, settings);
// force orientation in printer settings
if (orientationDefinition.Report.PaperOrientation == PaperOrientation.Landscape)
printerSettings.DefaultPageSettings.Landscape = true;
else
printerSettings.DefaultPageSettings.Landscape = false;
// print
_renderer.Document.PrinterSettings = printerSettings;
_renderer.Document.Print();
|
|
|
|
|
Report
|
|
|
|
|
GrapeCity » Product Support » Data Dynamics R... » Re: Printing report programmatically
|
|
|
|
|