Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 704341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:55:52+00:00 2026-05-14T03:55:52+00:00

I am having an issue with PageSettings.PrintableArea’s width and height values. Width, Height, and

  • 0

I am having an issue with PageSettings.PrintableArea’s width and height values. Width, Height, and Size properties claim to “get or set” the values. Also, the inflate() function claims to change the size based on values passed in.

However, all of these attempts to change the value have not worked. Inflate() is ignore (no error, just passes as if it worked, but the values remain unchanged.

Attempting to set the height, width, or size gives a compiler error: “Cannot modify the return value of ‘System.Drawing.Printing.PageSettings.PrintableArea’ because it is not a variable”.

I get the feeling that this means the “or set” part of the description is a lie.

Why I want to know this: (Someone always asks…) I have a printing application (C#, WinForm) that for most things is working rather well. I can set the printer settings and page settings objects to control what displays in the print dialog’s printer properties. However, with Microsoft Office Document Image Writer, these settings are sometimes ignored, and the paper size returns as 0, 0 even when it displayed something else. All I really want it for it to be WYSIWYG as far as the displayed values go, so I change the paper size back to what it should be, but the printable area, if it is wrong, makes the resulting image wonky. The resulting image is the size of the printable area instead of the value in papersize. Just wondering if there was a reason for this or a way to get it not to do that.

Thanks in advance. 🙂

UPDATE:

  //ignored 
  PrintDocument.DefaultPageSettings.PrintableArea.Inflate(XOffset, YOffset);

 //causes compiler error
 PrintDocument.DefaultPageSettings.PrintableArea.Size = new SizeF((float)DimensionsPaperSize.Width, (float)DimensionsPaperSize.Height);
 PrintDocument.DefaultPageSettings.PrintableArea.Height = DimensionsPaperSize.Height;
 PrintDocument.DefaultPageSettings.PrintableArea.Width = DimensionsPaperSize.Width;

UPDATE 2:

For my (custom size) printers that print correctly, when I change the PaperSize, the PrintableArea and PageBounds change automatically to match it. When I change the PaperSize on MDIW, only the PageBounds change. I don’t understand what’s causing that.

CONCLUSION:

Nobugz has done a great job explaining why PrintableArea cannot be set (and would normally never need to be) and why its inflate() function is ignored, so I’m marking that as the answer.

As far as the persistent problem that prompted me to ask this question, I’m still at a loss. In response to the ‘ScaleTranform’ suggestion, the PaperSize and Graphics objects have correct values already, so messing with those values aren’t likely to be of help. I suspect the most I could do along that route is resize my correctly-sized image to the garbage values I am getting for PrintableArea. I’m going to assume it is bug-related behaviour when explicitly setting PaperSize fails to modify the PrintableArea accordingly.

Its been frustrating that I seem to be the only person who has run into this problem. At least, so far I have only observed this behaviour for MODIW. For anyone’s reference, and so there is as much information out there as possible; I am running 32-bit Win7, developing in VS2008. To replicate the problem are these steps:

PrintDialog PrintDlg = new PrintDialog();
PrintDocument PrintDoc = new PrintDocument();
PrintDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(DocumentPrintPage);
PrintDlg.PrinterSettings.PrinterName = printerName; //MODIW
PrintDoc = AlterPaperSize(PrintDoc); //A function that just changes the papersize
PrintDlg.Document = PrintDoc;
PrintDlg.PrinterSettings = PrintDoc.PrinterSettings;
if (PrintDlg.ShowDialog() == DialogResult.OK)
{
   if ((PrintDoc.DefaultPageSettings.PaperSize.Width == 0) &&
       (PrintDoc.DefaultPageSettings.PaperSize.Height == 0))
   {
      PrintDoc.DefaultPageSettings.PaperSize = DimensionsPaperSize;
   }
   PrintDoc.Print();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:55:52+00:00Added an answer on May 14, 2026 at 3:55 am

    This is a pretty fundamental issue with .NET programming, every programmer falls for it at least once. The PrintableArea property type is RectangleF. That’s a structure, a value type. When you use the property, you get back a copy of the value.

    The compiler will notice that you are trying to modify a member of the copy, like when you try to assign the Height property. But it gets noddy when you use the Inflate() method. You are inflating the copy, not the original value and the compiler isn’t smart enough to notice.

    Key problem here is that the PrintableArea property only has a getter, it doesn’t have a setter. Which means that you can’t change it. Which makes sense if you think about it, you can’t change the size of the piece of paper nor change the design of the printer. You probably want to use the Margins property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.