Home All Groups Group Topic Archive Search About

Print Legal Size in System.Drawing.Printing

Author
27 Nov 2006 1:07 AM
Rick Lubanovic
Hi,

  I am having an issue trying to print using legal size.  I have a printer
that can successfully print legal size from Word, when the paper size is
selected in the print setup dialog.

  There is only one paper tray, and it can print letter or legal.  The code
which prints the letter size document draws a number of lines and text.
This works fine in letter mode.  This code is called from the WebService,
and the printer dialog is not available.  These settings must be done
programmatically.

  To switch to legal size, I tried the following in OnPrintPage:

if (fLegalSize){
for (int ii = 0; ii < ev.PageSettings.PrinterSettings.PaperSizes.Count;
ii++){
if (ev.PageSettings.PrinterSettings.PaperSizes[ii].Kind == PaperKind.Legal){
  ev.PageSettings.PaperSize =
ev.PageSettings.PrinterSettings.PaperSizes[ii];
break;}}}

  This sets the paper size to a Width = 1400 (landscape).  This seems ok.
However, when the print occurs, the left margin is 4 inches from the left of
the paper (1 inch is expected).  It appears that although the paper size is
properly set, the ev.Graphics object clip rectangle is using dimensions for
letter size.

  I assume that if I am using a printer with multiple paper trays, that the
PaperSource must be set to the legal tray for this to work.  In this case I
have only one tray.

  I have 2 questions:

  1. What do I have to do to properly set the PrintPageEventArgs for legal
size printing in OnPrintPage ?
  2. Is there a way to programmatically determine which tray in the printer
has legal paper ?  If not, I can set up configuration to select the proper
tray by name.

  This code is C# using the 1.1 Framework.

Thanks for the help.

AddThis Social Bookmark Button