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

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

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

图片转代码服务由CSDN问答提供 功能建议

我在Windwos php服务器上使用exec从php运行.bat文件,其中php使用快速运行 -cgi(和nginx)。 运行此脚本的命令行是

  pclose(popen(“start /”。$ cmd,“r”));  
   
 
 

其中$ cmd是某些东西,如“mybatfile.bat 45 1”

当我手动运行批处理文件时,它会运行 一个python程序来读取数据库,获取一些数据,并打印一个小报告。 这一切都正确地100%正常工作。

从网页运行时,报告出来,所以我知道程序已运行。 代码记录传递的参数。 我知道呼叫是正确的。

从服务器/网页运行时,报告显示在同一打印机上,比从coammnd线运行时大20%。

python脚本使用PyQt并以纯模式打开打印机。

代码是

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

有没有人 知道为什么会这样 - 我能做些什么来纠正它?

O / S是用于开发的Windows 7(64位)和用于生产的服务器版本。 Python 2.7 32位。 QT版本4.

谢谢 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.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题