Hello,
Could anyone show me how to interrogate the printer (or driver, I suppose) to return the size of paper currently in the printer, eg, Letter or A4? I think you could use a DEVMODE struct, but I will be honest, and say I don't know how to do it! I think Letter size would return 1, and A4 would be 15
Brian
I don't know if this may help (or not), but here is a library written in C and compiled with LCC.
More than 200 functions, documentation included and there's a working example written for PowerBAsic (i guess).
See attached zip archive.
I will take a look at that, thank you
And AstroGrep looks very useful. I have just downloaded it now
Brian
Well, I made a start on the printer DLL. Then I got stuck on the CopyMemory call. Too complicated for my tiny brain! Any ideas?
Brian
I found this as part of gdi+ for the vb.NET version but I couldn't find anything like it in the version we're using. Maybe someone who knows more will have better luck.
https://www.dotnetheaven.com/article/gdi-papersize-class-in-vb.net
LarryMc
I've been searching and it seems they always mention GetDeviceCaps, here it is an example, it looks easy to translate. No idea if is this what you are looking for.
ResolutionWidth& = GetDeviceCaps(Printer_hDC&, %LOGPIXELSX)
ResolutionHeight& = GetDeviceCaps(Printer_hDC&, %LOGPIXELSY)
pixelsLeftMargin& =GetDeviceCaps(Printer_hDC, %PHYSICALOFFSETX)
pixelsTopMargin& =GetDeviceCaps(Printer_hDC, %PHYSICALOFFSETY)
pixelsPrintWidth& = GetDeviceCaps(Printer_hDC&, %HORZRES)
pixelsPrintHeight& = GetDeviceCaps(Printer_hDC&, %VERTRES)
pixelsPhysicalWidth& = GetDeviceCaps(Printer_hDC, %PHYSICALWIDTH)
pixelsPhysicalHeight& = GetDeviceCaps(Printer_hDC, %PHYSICALHEIGHT)
PhysicalPaperWidthInch@ = pixelsPhysicalWidth&/ResolutionWidth&
PhysicalPaperHeightInch@ = pixelsPhysicalHeight&/ResolutionHeight&
LeftMarginInch@ = pixelsLeftMargin&/ResolutionWidth&
RightMarginInch@ = (pixelsPhysicalWidth& - pixelsPrintWidth& - pixelsLeftMargin&)/ResolutionWidth&
TopMarginInch@ = pixelsTopMargin&/ResolutionHeight&
BottomMarginInch@ = (pixelsPhysicalHeight& - pixelsPrintHeight& - pixelsTopMargin&)/ResolutionHeight&
https://forum.powerbasic.com/forum/user-to-user-discussions/programming/17995-getphyspagesize
PD: AstroGrep looks very useful, indeed. I still have to try Andy's program.
duh!
I've got some of those calcs in my print preview code in the IWB IDE!
Sorry :P
My brain hasn't been working too well here lately.
Hi every one.
This is how to do it easily, as I have said before, the registry holds many things in it.
Attached is the program.
All printers are in the registry key...
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers
Most printers (physical or software) have a sub folder called "DsDriver".
In the "DsDriver" sub key there is an entry called "printMediaReady".
"printMediaReady" has the default paper size value.
The command GETDEFAULTPRINTER looks at the key...
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows
In here the default printer is listed with some other things as well, on my PC the entry "Device" has this...
HP DJ 2130 series,winspool,Ne02: (my printer - HP DJ 2130 series - before the first comma)
Andy.
:)
Larry, it happens to me all the time. Also, I take a break from time to time, and when I come back I have no idea what I was doing ^^ Andy, I don't have a printer but I can spot printMediaReady as you stated inside 'Microsoft Print to PDF' with a value of "A4".
Well spotted,
Yes even most "software" printers will have an entry.
Andy.
:)