tim freese
asked on
Print Document - Change Margins
good day.
i am having trouble defining the margins when printing a document.
the text is printing down the middle of the page. i want the left hand margin to be nominal. my setting below is .10"; however, it isn't working.
any help would be appreciated.
thanks.
void pd_PrintPage(object sender, PrintPageEventArgs e)
{
int charactersOnPage = 0;
int linesPerPage = 0;
e.PageSettings.Margins.Lef t = 10;
e.PageSettings.Margins.Rig ht = 25;
e.PageSettings.Landscape = false;
// Sets the value of charactersOnPage to the number of characters
// of stringToPrint that will fit within the bounds of the page.
Font ft = new Font(FontFamily.GenericMon ospace, 8);
e.Graphics.MeasureString(p ickList, ft,
e.MarginBounds.Size, StringFormat.GenericTypogr aphic,
out charactersOnPage, out linesPerPage);
// Draws the string within the bounds of the page
e.Graphics.DrawString(pick List, ft, Brushes.Black,
e.MarginBounds, StringFormat.GenericTypogr aphic);
// Remove the portion of the string that has been printed.
pickList = pickList.Substring(charact ersOnPage) ;
// Check to see if more pages are to be printed.
e.HasMorePages = (pickList.Length > 0);
}
i am having trouble defining the margins when printing a document.
the text is printing down the middle of the page. i want the left hand margin to be nominal. my setting below is .10"; however, it isn't working.
any help would be appreciated.
thanks.
void pd_PrintPage(object sender, PrintPageEventArgs e)
{
int charactersOnPage = 0;
int linesPerPage = 0;
e.PageSettings.Margins.Lef
e.PageSettings.Margins.Rig
e.PageSettings.Landscape = false;
// Sets the value of charactersOnPage to the number of characters
// of stringToPrint that will fit within the bounds of the page.
Font ft = new Font(FontFamily.GenericMon
e.Graphics.MeasureString(p
e.MarginBounds.Size, StringFormat.GenericTypogr
out charactersOnPage, out linesPerPage);
// Draws the string within the bounds of the page
e.Graphics.DrawString(pick
e.MarginBounds, StringFormat.GenericTypogr
// Remove the portion of the string that has been printed.
pickList = pickList.Substring(charact
// Check to see if more pages are to be printed.
e.HasMorePages = (pickList.Length > 0);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.