cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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);
                    oTable.SetDataSource(dt);
                }
                report.PrintOptions.PrinterName = PrinterName;
                PageMargins margins = new PageMargins(288, 3024, 360, 1440);
                report.PrintOptions.ApplyPageMargins(margins);
                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");

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Seems like my large value for top margin(2.2 inches) created this abnormal behavior. I changed the top border to .25 inches and added white space to adjust.

Not sure whether this should be called a bug of Crystal Reports. Anyone met with similar issues?

Former Member
0 Kudos

I'm terribly stuck with this issue. Anyone got a solution?