dongzhou5344 2010-08-28 20:44
浏览 94
已采纳

为何打印机会改变分辨率? 用户,背景,什么?

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

  • 写回答

1条回答 默认 最新

  • dongza5150 2010-08-29 15:21
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!