I have a problem with PageSettings.PrintableArea width and height values. The Width, Height, and Size properties claim to "get or set" values. In addition, the inflate () function claims to resize based on the values passed in.
However, all these attempts to change the meaning did not work. Inflate () is ignored (no error, just passes as if it worked, but the values remain unchanged.
Trying to set the height, width, or size gives a compiler error: "Unable to change the return value" System.Drawing.Printing.PageSettings.PrintableArea "because it is not a variable."
I get the feeling that this means that the “or given” part of the description is a lie.
Why I want to know this: (Someone always asks ...) I have a print application (C #, WinForm), which works pretty well for most things. I can configure printer settings and page settings to control what is displayed in the properties of the print dialog box. However, with the Microsoft Office Document Image Writer, these options are sometimes ignored, and the paper size is returned as 0, 0, even when it displays something else. All I really want is WYSIWYG, as far as the displayed values go, so I change the paper size to what it should be, but the print area, if it is wrong, makes the resulting image uncomfortable. The resulting image is the size of the printable area instead of the value in the document. Just wondering if there is a reason for this or a way to make him not do it.
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 (non-standard) printers that print correctly, when I change, PaperSize, PrintableArea, and PageBounds automatically change to fit them. When I change PaperSize to MDIW, only PageBounds change. I do not understand what it means.
CONCLUSION:
Nobugz did an excellent job explaining why PrintableArea cannot be installed (and usually should never be) and why its inflate () function is ignored, so I mark this as an answer.
Regarding the ongoing problem that prompted me to ask this question, I am still out of order. PaperSize and Graphics objects already have the correct values in response to the ScaleTranform clause, so using these values is unlikely to help. I suspect that most of all I could do along this route by resizing the image with the correct size to the garbage values that I get for PrintableArea. I assume this is due to an error when explicit setting of PaperSize does not allow to change PrintableArea accordingly.
He was disappointed that I, it seems, is the only person who has encountered this problem. At least so far I have observed this behavior only for MODIW. For any reference, and therefore there is as much information as possible; I am running 32-bit Win7 being developed in VS2008. To reproduce the problem, follow these steps:
PrintDialog PrintDlg = new PrintDialog(); PrintDocument PrintDoc = new PrintDocument(); PrintDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(DocumentPrintPage); PrintDlg.PrinterSettings.PrinterName = printerName;