Data Dynamics Reports Support

Started by dobbo at 07-13-2007 6:31 AM. Topic has 13 replies.

Print Search Rate
Sort Posts:    
   07-13-2007, 6:31 AM
dobbo is not online. Last active: 7/11/2007 1:43:59 PM dobbo

Not Ranked
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 is not online. Last active: 2/1/2012 6:50:14 PM Jon Smith - DD

Top 25 Posts
Joined on 02-21-2007
Raleigh, NC
Posts 958

DDStaff
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 is not online. Last active: 7/11/2007 1:43:59 PM dobbo

Not Ranked
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 is not online. Last active: 2/1/2012 6:50:14 PM Jon Smith - DD

Top 25 Posts
Joined on 02-21-2007
Raleigh, NC
Posts 958

DDStaff
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 is not online. Last active: 2/1/2012 6:50:14 PM Jon Smith - DD

Top 25 Posts
Joined on 02-21-2007
Raleigh, NC
Posts 958

DDStaff
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 is not online. Last active: 7/11/2007 1:43:59 PM dobbo

Not Ranked
Joined on 07-10-2007
Posts 9
Re: Printing report programmatically
Thanks Jon.
   Report 
   03-02-2008, 8:01 PM
rolandg is not online. Last active: 5/9/2008 10:06:16 PM rolandg

Not Ranked
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 is not online. Last active: 2/1/2012 6:50:14 PM Jon Smith - DD

Top 25 Posts
Joined on 02-21-2007
Raleigh, NC
Posts 958

DDStaff
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 is not online. Last active: 2/9/2012 4:15:43 AM paulywally

Top 500 Posts
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 
   02-10-2009, 1:45 AM
Sergey is not online. Last active: 6/29/2011 11:13:11 PM Sergey

Top 10 Posts
Joined on 08-28-2004
Novosibirsk, Russia
Posts 3,015

DDStaff
Re: Printing report programmatically
Hello,
MSDN says: "Do not confuse this class, System.Windows.Controls.PrintDialog, with System.Windows.Forms.PrintDialog. The latter is used with Windows Forms applications. System.Windows.Controls.PrintDialog is used with Windows Presentation Foundation (WPF) applications." AFAIK there is no way to use WPF PrintDialog to collect the printer settings needed for printing by using PrintDocument class. As far as I inderstand you are using the custom report viewer toolbar which is built by using WPF and want to print the report programmatically once user selects the print settings in the custom print dialog(WPF)? If so, the only way to meet this goal is using custom print dialog which can retrive the PrinterSettings class or using
System.Windows.Controls.PrintDialog form...

HTH


Sergey Abakumoff
GrapeCity
   Report 
   05-21-2009, 11:25 AM
paulywally is not online. Last active: 2/9/2012 4:15:43 AM paulywally

Top 500 Posts
Joined on 01-30-2009
Posts 40
Re: Printing report programmatically

Attachment: TeamList.rdlx
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 is not online. Last active: 6/22/2009 9:57:37 PM SandeepS

Top 50 Posts
Joined on 12-11-2008
Posts 269

DDStaff
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 is not online. Last active: 6/22/2009 9:57:37 PM SandeepS

Top 50 Posts
Joined on 12-11-2008
Posts 269

DDStaff
Re: Printing report programmatically

Attachment: PrntInLandscape.zip
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 is not online. Last active: 2/9/2012 4:15:43 AM paulywally

Top 500 Posts
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

Privacy Policy | Copyright © 1997-2012 — GrapeCity, inc.
All trademarks mentioned are the property of their respective owners.