views:

32

answers:

1

Hi, I am runing a .bat file from a php using exec on a Windwos php server, where php is run using fast-cgi (and nginx). The command line to run this script is

  pclose(popen("start / ". $cmd, "r"));  

Where $cmd is somethign like "mybatfile.bat 45 1"

When I run the batch file manually it runs a python program to read a database, get hold of some data, and print a little report. And it all works 100% correctly.

When it is run from the web page, the report comes out, so I know the program is run. The code logs the parameters passed. I know that the call is correct.

When run from the server/web page the report appears on the same printer approx 20% larger that when run from the coammnd line.

The python script uses PyQt and opens the printer in native mode.

The code is

    self.printer = QPrinter()
    self.printer.setPrinterName(printer)
    self.printer.setPageSize(QPrinter.A5)
    self.printer.setOrientation(QPrinter.Portrait)
    self.painter = QPainter(self.printer)

Does anyone know why this happens - and what can I do to correct it?

O/S is windows 7 (64 bit) for developement and a Server version for production. Python 2.7 32 bit. QT version 4.

Thanks Ian

A: 

Cracked it! The user who is running the server has never logged in (naturally) so they have never changed their screen resolution from 90 dpi.

I on the other hand, have changed by screen resolution because I use large fonts. So when I ran the print it printed in 120 dpi. When the server ran it, it printed in 90 dpi.

Solution.

After opening the printer, read the actual resolution back, and compute a scale factor.

Use the scale factor for all layout and positioning - except font sizes in points which will be correct anyway.

Ian