|
|||
|
Hi,
I need to get the priysical size of page in onPrint event handler. There is no such methods or properties in Printer object. I tried to use a Dll object and WinAPI: //--- Dll.registerFunction ("gdi32.dll", "CreateDCA", "CreateDC", "stdcall", "long*", "string", "string", "string", "long"); Dll.registerFunction ("gdi32.dll", "GetDeviceCaps", "getDeviceCaps", "stdcall", "long", "long*", "long"); var Hdc = CreateDC("WINSPOOL", Printer.printers[1], null, null); PhysicalWidth= getDeviceCaps(Hdc, 110); //--- But getDeviceCaps returns "undefined". Is this code right? Is there any way to get the physical page size? Help me please. |
|
|||
|
Thank you.
But it is useless for my case. paperSize, pageWidth and pageHeight are not enough. I need center image on PHYSICAL PAGE so I need to obtain these GetDeviceCaps values: PHYSICALWIDTH - physical page width [dots] PHYSICALHEIGHT - physical page height [dots] PHYSICALOFFSETX - horizontal offset from physical page edge to logical page edge [dots] PHYSICALOFFSETY - vertical offset from physical page edge to logical page edge [dots] Is this possible? Thanks. |
|
|||
|
Please use the Printer.getImageSize method to get the logical size of an image
Code:
var w = this.pageWidth; var h = this.pageHeight; var is = this.getImageSize(image); var left = (w - is.width) / 2; var top = (h - is.height) / 2; this.printImage(image, left, top, is.width, is.height); |
|
|||
|
Thank you.
Your code allows to center image inside the logical page. But the logical page often is not centered inside the physical page. That's why I need PhysicalWidth, PhysicalHeight, PhysicalXOffset, PhysicalYOffset. It must be something like this: var w = this.pageWidth; var h = this.pageHeight; var xCorrection = (PhysicalWidth - w)/2 - XOffset; var yCorrection = (PhysicalHeight - h)/2 - YOffset; var is = this.getImageSize(image); var left = (w - is.width) / 2 + xCorrection ; var top = (h - is.height) / 2 + yCorrection ; this.printImage(image, left, top, is.width, is.height); Thanks. |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|