Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

PrintToPrinter is having incorrect margins (Export to PDF is working fine)

I've met with a strange situation where my report wont print properly when I use PrintToPrinter from .NET application. But if I export or preview it in the designer it works as expected. When I print, margins set in the reports are lost. How can I make sure PrintToPrinter prints the same way as I export to PDF?

                Reports.Sales.Invoice report = new Reports.Sales.Invoice();
                foreach (CrystalDecisions.CrystalReports.Engine.Table oTable in report.Database.Tables)
                    DataTable dt = LoadSalesData(SalesId);
                report.PrintOptions.PrinterName = PrinterName;
                PageMargins margins = new PageMargins(288, 3024, 360, 1440);
                report.PrintOptions.PaperOrientation = PaperOrientation.Portrait;
                report.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLetter;
                report.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Auto;
                report.PrintToPrinter(1, false, 0, 0);
                report.ExportToDisk(ExportFormatType.PortableDocFormat, "Invoice.pdf");

Former Member
Not what you were looking for? View more on this topic or Ask a question