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.

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

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP