Report.PageSettings.Landscape = true;
However when I click print button the default printer setting is Portrait. I cannot convince my customer to have Landscape as a system wide default setting so I need to change it before opening PrintDialog. It can be done too:
PrintDialog dialog = new PrintDialog();
LocalPrintServer.GetDefaultPrintQueue().DefaultPrintTicket.PageOrientation = PageOrientation.Landscape;
dialog.PrintQueue = LocalPrintServer.GetDefaultPrintQueue();
dialog.PrintTicket = dialog.PrintQueue.DefaultPrintTicket;
dialog.PrintTicket.PageOrientation = PageOrientation.Landscape;
dialog.ShowDialog();
The problem is that ReportProcessor.PrintReport does not accept PrintTicket (returned by PrintDialog) and want PrinterSettings which are not available under .NET 3.5.
Is there any way to overcome the problem?
Any suggestion would be appreciated
12 Answers, 1 is accepted
What is the type of application you try this in? Also when you say "when I click print button", do you refer to the Print button in a report viewer toolbar or your own UI that invokes the ReportProcessor.PrintReport() code? It would be great if you send us a runnable sample application with a problematic report in LandScape, so that we can investigate what is happening. Once we have more info, we would be able to advise you accordingly.
Regards,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

The scenario I am trying to implement is simple.
Pre-condition: the DefaultPrinter default paper orientation is Portrait.
My report default page orientation is Landscape and I set it in the host Window constructor:
public Window1()
{
InitializeComponent();
ReportViewer1.Report.PageSettings.Landscape = true;
}
I click print button on the report viewer and PrinterDialog pops up with the default printer highlighted. The problem is that if I click print button in the dialog it will print in Portrait. I cannot expect my customer to go in printer preferences of the highlighted printer and change the orientation every time he/she prints.
I thought that I can overcome the problem by createing a custom print button and opening PrinterDialog from its OnClick handler. And just before calling ShowDialog I would set the initial orientation to Landscape (see the sample application).
var dialog = new PrintDialog();
dialog.PrintQueue = LocalPrintServer.GetDefaultPrintQueue();
dialog.PrintTicket = dialog.PrintQueue.DefaultPrintTicket;
dialog.PrintTicket.PageOrientation = PageOrientation.Landscape;
dialog.ShowDialog();
Yes it works but the problem is that after closing the PrinterDialog the user final printer selection is stored in the PrinterDialog.PrinterTicket and it cannot be used later with ReportProcessor.PrintReport() as it requires printer selection to be passed as PrinterSettings instance. And as you are probably aware PrenetrSettings became logically obsolete in .NET3.5.
Thus I see two problems here:
1. ReportViewer PrintButton routine does not propagate ReportViewer1.Report.PageSettings.Landscape to the PrinterDialog.
2. ReportProcessor.PrintReport() does not allow supplying printer settings as PrintTicket object.
I have prepared the sample application, which is a slightly modified version of the WpfDemo from the Q1 2010 package.
Please find the sample application here: http://dl.dropbox.com/u/956512/Telerik/WpfDemo_PrinterSettings.zip
Thanks
Thank you for sending the sample project and elaborating on the problem.
Indeed, when using the Print button from the WPF report viewer the Landscape property is not respected and the report is printed with the default value of the printer settings. Of course, changing the system wide settings is not an acceptable solution so we will log and fix this issue for the next release or internal build.
If you prefer to implement your own printing method, here is a sample code snippet to illustrate a possible approach. In order to take advantage of the new PrintDialog class in .net 3.5 you can use an xps document to print through:
private
void
button1_Click(
object
sender, RoutedEventArgs e)
{
var dialog =
new
PrintDialog();
dialog.PrintQueue = LocalPrintServer.GetDefaultPrintQueue();
dialog.PrintTicket = dialog.PrintQueue.DefaultPrintTicket;
dialog.PrintTicket.PageOrientation = (
this
.ReportViewer1.Report.PageSettings.Landscape)
? PageOrientation.Landscape
: PageOrientation.Portrait;
if
(dialog.ShowDialog() ==
true
)
{
var reportProcessor =
new
ReportProcessor();
var deviceInfo =
new
System.Collections.Hashtable();
var result = reportProcessor.RenderReport(
"XPS"
, ReportViewer1.Report, deviceInfo);
var tempName = System.IO.Path.GetTempFileName();
using
(var fileStream =
new
FileStream(tempName, FileMode.Create))
{
fileStream.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}
using
(var document =
new
XpsDocument(tempName, FileAccess.Read))
{
var fixedDocSeq = document.GetFixedDocumentSequence();
dialog.PrintDocument(fixedDocSeq.DocumentPaginator, result.DocumentName +
""
);
}
try
{
File.Delete(tempName);
}
catch
{ }
}
}
The ReportProcessor.Print report method does respect the Landscape property of the report so you do not have to explicitly change or set it. You can use it if the report will be printed with the default printer settings as if without showing the PrintDialog. For now it is unlikely that this method will be changed to use the PrintTicket class as the reporting engine currently being build against .net framework 2.0.
Best wishes,
Chavdar
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

The work around is an acceptable solution.
Cheers

If I save the report it is Landscape as it should be.
If I take the default print settings it's portrait?
Help!
Other FYI
I was also using a custom control template for the Silverlight ReportViewer and I had to delete that resource to make the control behave correctly. I wouldn't print anything. Now it prints just not in the right direction.
In Q3 2010 we introduced native Silverlight print, which is set as default. However the Silverlight document print has very limited API which does not allow for us to specify the orientation. Thus for in browser applications we have exposed UseNativePrinting property for the Silverlight viewer - please set it to false. This will force the Silverlight Report Viewer to revert to the previous printing behavior using Adobe's PDF plug-in. Note however that this would not work for out of browser applications.
As for the custom template - I was not able to reproduce such problem on our end. The viewer print/export worked correctly after creating a custom template with Blend.
Regards,
Steve
the Telerik team

The Print preview in the viewer will render the report based on the Understanding Pagination article and the report's PageSettings properties. Setting the report's PageSettings as Landscape and PaperKind will be enough to print the report as required.
I hope the provided information is helpful.
Regards,
Stef
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Thank you for your reply. But my issue is that my page settings are set correctly - Landscape and Letter, and Report Viewer print preview shows them correctly too. But when i press print button and try to send report to the printer - my settings are not translated directly to printer settings, but instead my last saved printer configuration or just some default, which for some users always Portrait and Letter, is used. And i can not expect that users will manually set up printing configuration even once. So my issue is that after clicking print button my report print settings not passed to the printer settings, but instead last or saved printer configuration is used. And i believe that i can somehow override report viewer print button to manually setup printer settings before sending report to printer. I just not sure how can i do it
Best regards,
Anna
The report will be rendered with the PDF rendering mechanism and sent to the client. All report's PageSettings will be taken into account and the produced document should look as the Print Preview of the report in the viewer. Then it is the browser's PDF plugin which handles the print operation, and the client's machine printer settings which may affect the result.
Please test the following:
- Print the report on other printer and from other machine.
- Test printing an exported PDF and if the result is as the expected.
Regards,
Stef
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Hello,
I also have the same issue. I am generating a report with settings - A3; Landscape; color. While using print option in the the Web viewer, the system dialog defaults to A4; portrait.
Is there any way to resolve this?
Thanks
Gautam
The print feature of web viewers is based on an export in PDF with injected Adobe JavaScript forcing the browser's PDF plugin to open its Print dialog, when the bytes of the PDF are returned to the client and loaded in browser.
The PDF plugin's Print dialog is out of the scope of the reporting engine. Some print settings can be affected by Adobe JavaScript settings that can be included in the report e.g. check this example.
Regards,
Stef
Telerik by Progress