Link to home
Start Free TrialLog in
Avatar of tim freese
tim freeseFlag for United States of America

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.Left = 10;
            e.PageSettings.Margins.Right = 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.GenericMonospace, 8);
            e.Graphics.MeasureString(pickList, ft,
                e.MarginBounds.Size, StringFormat.GenericTypographic,
                out charactersOnPage, out linesPerPage);

            // Draws the string within the bounds of the page
            e.Graphics.DrawString(pickList, ft, Brushes.Black,
                e.MarginBounds, StringFormat.GenericTypographic);

            // Remove the portion of the string that has been printed.
            pickList = pickList.Substring(charactersOnPage);

            // Check to see if more pages are to be printed.
            e.HasMorePages = (pickList.Length > 0);
        }
ASKER CERTIFIED SOLUTION
Avatar of tim freese
tim freese
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial