Print in landscape orientation and adjust a printout's margins in C#

By default, when you display a print preview or print a document, the document appears in portrait orientation with one inch margins. To change that, set the PrintDocument's DefaultPageSettings properties before displaying the preview as in the following code.
// Display the print preview.
private void btnGo_Click(object sender, EventArgs e)
{
pdocTriangle.DefaultPageSettings.Margins =
new System.Drawing.Printing.Margins(50, 50, 50, 50);
pdocTriangle.DefaultPageSettings.Landscape = true;
ppdTriangle.ShowDialog();
}

This code sets the page's margins to half inch (measured in hundredths of inches) and makes it appear in landscape orientation. It then displays the print preview dialog.

   

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this post.
Comments
  • No comments exist for this post.
Leave a comment

Submitted comments are subject to moderation before being displayed.

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.