Resolved PrinterSettings vs Wordpad

aaaron123@roadrunner.com

Well-known member
Joined
Jan 23, 2011
Messages
110
Programming Experience
10+
P for portrait and L for Landscape

PRINTERHP C310 PHP 301 LHP C8180 PHP C8180 L
LEFT0.130.160.130.07
TOP0.1250.130.070.13
RIGHT0.130.1250.130.16
BOTTOM0.160.130.160/13
The above table shows the hard margins for two printers from Wordpad.

I set all margins to zero then Wordpad fixed the values to the above.

It shows C310 rotates the text 90 degrees CW (Top went to right)

and C8180 rotates text 90 CCW. (Top went to left)



Notepad rotates similarly

It does not appear that Wordpad and Notepad use the same code since they show similar but slightly different values.



From PrinterSettings I find:

That C310 rotates text 90 degrees CCW

And C8180 rotates text 90 degrees CW.

To find this I used debugging to capture some values from PrinterDocument:

PrinterSettings HP Photosmart Prem C310 series Copies=1 Collate=True Duplex=Simplex FromPage=0 LandscapeAngle=90 MaximumCopies=9999



PrinterSettings HP Photosmart C8100 series Copies=1 Collate=True Duplex=Simplex FromPage=0 LandscapeAngle=270 MaximumCopies=9999



And MS documentation:

Specifying Paper Orientation - Windows drivers | Microsoft Docs

The LANDSCAPE_CC90 option rotates text and graphics 90 degrees counterclockwise. The LANDSCAPE_CC270 option rotates text and graphics 270 degrees counterclockwise, which is equivalent to a rotation by 90 degrees clockwise.

So what do I conclude?

Old as the hills Wordpad and Notepad are wrong?

Printsettings can't be trusted?

I misconscrewed something?



Unfortunately I do not have a printer available so the data that could come from actually printing is missing.

I wrote a program that uses the hard margins and I'd like to feel confident that I'm using them correctly. I'm hoping that you may have bumped into to this in the past and may be willing to add to what I've posted.



 

aaaron123@roadrunner.com

Well-known member
Joined
Jan 23, 2011
Messages
110
Programming Experience
10+
PRINTERHP C310 PHP 301 LHP C8180 PHP C8180 L
LEFT0.130.160.130.07
TOP0.1250.130.070.13
RIGHT0.130.1250.130.16
BOTTOM0.160.130.160/13
Windows calls them hard margins. I call them minimum margins because the printer itself demands them. I first used Wordpad to determine how text is rotated on the page in landscape mode. Then checked to see if various software correctly uses the correct hard margins in landscape. This is an old problem and there is much on the internet. One thing I did not find on the Internet is the fact that some printers rotate 90 derees and other rotate 270 degrees.

This table above contains the hard margins used by Wordpad for two printers.

In it P is for portrait and L is for Landscape

The above table shows the hard margins for two printers from Wordpad.

I set all margins to zero then Wordpad fixed the values to the above.

It shows C310 rotates the text 90 degrees CW (Top when to right)

and C8180 rotates text 90 CCW. (Top went to left)

Notepad rotates similarly

It does not appear that Wordpad and Notepad use the same code since they show similar but slightly different values.



From PrinterSettings I find:

That C310 rotates text 90 degrees CCW

And C8180 rotates text 90 degrees CW.

To find this I used debugging to capture some values from PrinterDocument:

PrinterSettings HP Photosmart Prem C310 series Copies=1 Collate=True Duplex=Simplex FromPage=0 LandscapeAngle=90 MaximumCopies=9999 OutputPort= ToPage=0​

(I don't know why this editor insist the above must be darker)

PrinterSettings HP Photosmart C8100 series Copies=1 Collate=True Duplex=Simplex FromPage=0 LandscapeAngle=270 MaximumCopies=9999 OutputPort= ToPage=0



And find the following in MS documentation:

Specifying Paper Orientation - Windows drivers | Microsoft Docs

The LANDSCAPE_CC90 option rotates text and graphics 90 degrees counterclockwise. The LANDSCAPE_CC270 option rotates text and graphics 270 degrees counterclockwise, which is equivalent to a rotation by 90 degrees clockwise.

So it appears that Wordpad and Notepad conflict with DotNET

So what do I conclude?

Old as the hills Wordpad and Notepad are wrong?

Printsettings can't be trusted?

I misconscrewed something?

Unfortunately I do not have a printer available so the data that could come from actually printing is missing.

I may have missed it but I believe initially DotNET ignored the hard margins and simply consider the printable space. So I compensated in software myself. At that time I was unaware of the 270 degree possibility. Anyway I'm trying to revist it and think there must be other who have already looked at this and may be willing to share conclusions with.

Since my first post I now think I'l simply ignore what looks to me as Wordpad and Notepad bugs.
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,538
Location
Norway
Programming Experience
10+
Solution

aaaron123@roadrunner.com

Well-known member
Joined
Jan 23, 2011
Messages
110
Programming Experience
10+
I use to use GdiDll.GetDeviceCaps. I did the following sometime ago (still unaware of 90 vs 270)


VB.NET:
 'Dim leftPrinterOffsetHI As Integer = CInt(GdiDll.GetDeviceCaps(hDc, WinGdiH.PHYSICALOFFSETX) / PrinterDpiXP * 100)
'Dim topPrinterOffsetHI As Integer = CInt(GdiDll.GetDeviceCaps(hDc, WinGdiH.PHYSICALOFFSETY) / PrinterDpiYP * 100)
    
            leftPrinterOffsetH = CInt(pDDefaultPageSettings.HardMarginX) 'These do not change for landscape
            topPrinterOffsetH = CInt(pDDefaultPageSettings.HardMarginY)


I converted to DefaultPageSettings but, like GetDeviceCaps, DefaultPageSettings does not compensate for landscape.

I did in my code but was unaware that there were two classes of printers (the 90 degree and the 270 degree kinds)

I was looking at Wordpad as a way of checking my code. It just occurred to me that the reason their code looked incorrect is maybe because I, without thinking, had coded to one type (90 or 270) and they coded to the other type. Maybe depending on whatever printer was available.

Thanks for the response. I'll look at DeviceCapabilities out of curiosity but I think I can now do everything using Net


EDIT: I see DeviceCapabilities/DC_ORIENTATION includes 90 vs 270
 
Last edited:

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,538
Location
Norway
Programming Experience
10+
Top Bottom