I've inherited an application created by people who are no longer working for my employer and I'm looking into a printing issue where the output (slightly) falls off the page.

It should be:

enter image description here

But it comes out like this:

enter image description here

I've added the black borders for legibility on this page.

So as you can see, the print is shifted slightly to the right and to the bottom, so that it surpasses the allowed boundaries.

My question

I'm going through the code, looking for options that may cause this, but I'm drawing a blank right now.

Option A (ideal solution):

Any ideas on what may be causing this shift to the right-bottom?

Option B

Any idea how I can shrink the scaling of what's being printed, so that the content no longer falls off the page?

Let me know if you need code to help clear out what's going on (I can't narrow things down enough up front to post any).

This question had a bounty worth +50 reputation from Spikee that ended 6 hours ago. Grace period ends in 17 hours

Looking for an answer drawing from credible and/or official sources.

  • 2
    Looks like a mechanical problem to me, the paper is not quite aligned correctly. It bit too far to the left and in. In fact, the printout looks designed to show exactly such a problem. Do ask somebody in the your company that's been around for a while what its intention was. In which case there should be a documented procedure to adjust the paper feed mechanism. – Hans Passant Sep 21 at 16:03
  • I used the print out exactly to test how skewed the print is, because I noticed that the margins were off even though they are at 0. And it's not the printer itself, because if I print it directly it's fine, its only when I print via code that it's off. – Spikee Sep 21 at 22:20
  • If you downvote, please note why. – Spikee Sep 24 at 11:28
  • 1
    Hi, would you be able to solve this problem just by looking at those images? I think you should include your code, otherwise it's impossible to provide an answer... – Isma Sep 25 at 11:40
  • at least tell us what control are you using. I have absolutely no clue what these white rectangles are. – Bizhan Sep 25 at 15:21

Since you didn't published your code, It's a bit harder to answer your question but here are 2 solutions to your problem:

on your System.Drawing.Printing.PrintDocument class, override the default OnPrintPage and change the page margins:

protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e)
{
    base.OnPrintPage(e);
    // Create a new instance of Margins with 1-inch margins.
    e.PageSettings.Margins = new System.Drawing.Printing.Margins(100, 100, 100,100);
}

you can read more about the Margins property in here

you can also play with the settings in the follow way:

        protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e)
        {
            // Run base code
            base.OnPrintPage(e);

            //Declare local variables needed

            int printHeight;
            int printWidth;
            int leftMargin;
            int rightMargin;
            Int32 lines;
            Int32 chars;

            //Set print area size and margins
            {
                printHeight = base.DefaultPageSettings.PaperSize.Height - base.DefaultPageSettings.Margins.Top - base.DefaultPageSettings.Margins.Bottom;
                printWidth = base.DefaultPageSettings.PaperSize.Width - base.DefaultPageSettings.Margins.Left - base.DefaultPageSettings.Margins.Right;
                leftMargin = base.DefaultPageSettings.Margins.Left;  //X
                rightMargin = base.DefaultPageSettings.Margins.Top;  //Y
            }
        }

you should read that following guide to learn and change it to fit your own needs

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.