E
egarcia1970
Hi group.
I'm having problems getting this C# code to print in landscape
orientation:
private void MyPrintDocument_BeginPrint(object sender,
System.Drawing.Printing.PrintEventArgs e)
{
MyPrintDocument.PrinterSettings.DefaultPageSettings.Landscape = true;
MyPrintDocument.PrinterSettings.DefaultPageSettings.Margins.Left = 25;
MyPrintDocument.PrinterSettings.DefaultPageSettings.Margins.Right = 25;
MyPrintDocument.PrinterSettings.DefaultPageSettings.Margins.Top = 50;
MyPrintDocument.PrinterSettings.DefaultPageSettings.Margins.Bottom =
50;
}
private void MyPrintDocument_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
if (k < MyReportReader.Pages.Count)
{
if (chklstBills.GetItemCheckState(k) ==
CheckState.Checked)
{
e.HasMorePages = true;
Font prFont = new Font("Courier New", 10,
GraphicsUnit.Point);
Page currentPage = (Page)MyReportReader.Pages[k];
int j;
for (j = 0; j < currentPage.Lines.Count; j++)
{
float x, y;
x = 26;
y = 50 + (float)j * (float)12.5;
e.Graphics.DrawString(currentPage.Lines[j].ToString(), prFont,
Brushes.Black, x, y);
}
}
k++;
}
else
{
e.HasMorePages = false;
}
}
ReportReader and Page are custom classes for this application
MyPrintDocument is an instance of the PrintDocument class.
Using .NET framework 2.0
This code prints in portrait orientation in any printer no matter what
I do, ignoring the
'MyPrintDocument.PrinterSettings.DefaultPageSettings.Landscape = true'
statement in the BeginPrint event handler. It's not a printer problem.
Any help will be greatly appreciated.
I'm having problems getting this C# code to print in landscape
orientation:
private void MyPrintDocument_BeginPrint(object sender,
System.Drawing.Printing.PrintEventArgs e)
{
MyPrintDocument.PrinterSettings.DefaultPageSettings.Landscape = true;
MyPrintDocument.PrinterSettings.DefaultPageSettings.Margins.Left = 25;
MyPrintDocument.PrinterSettings.DefaultPageSettings.Margins.Right = 25;
MyPrintDocument.PrinterSettings.DefaultPageSettings.Margins.Top = 50;
MyPrintDocument.PrinterSettings.DefaultPageSettings.Margins.Bottom =
50;
}
private void MyPrintDocument_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
if (k < MyReportReader.Pages.Count)
{
if (chklstBills.GetItemCheckState(k) ==
CheckState.Checked)
{
e.HasMorePages = true;
Font prFont = new Font("Courier New", 10,
GraphicsUnit.Point);
Page currentPage = (Page)MyReportReader.Pages[k];
int j;
for (j = 0; j < currentPage.Lines.Count; j++)
{
float x, y;
x = 26;
y = 50 + (float)j * (float)12.5;
e.Graphics.DrawString(currentPage.Lines[j].ToString(), prFont,
Brushes.Black, x, y);
}
}
k++;
}
else
{
e.HasMorePages = false;
}
}
ReportReader and Page are custom classes for this application
MyPrintDocument is an instance of the PrintDocument class.
Using .NET framework 2.0
This code prints in portrait orientation in any printer no matter what
I do, ignoring the
'MyPrintDocument.PrinterSettings.DefaultPageSettings.Landscape = true'
statement in the BeginPrint event handler. It's not a printer problem.
Any help will be greatly appreciated.