2017-08-07 7 views
0

私はサーマルプリンタを持っており、領収書の上にロゴを印刷したいと思います... png画像用のshutil.copyfileなどのものはありますか?Pythonはデフォルトのプリンタにpngファイルを送信します

私のコードでは、これは私が見つけることができたソリューションです

locations = ['/dev/usb/lp0', '/dev/usb/lp1', '/dev/usb/lp2'] 
     size = locations.__len__() 
     i = 0 

     while i < size: 
      printer = locations[i] 
      try: 
       shutil.copyfile('output.txt', printer) 
       break 
      except IOError: 
       i += 1 

     if i == size: 
      logging.error('Unable to connect to the printer') 
+0

'size = len(locations)' ..私たちはreportlab(https://bitbucket.org/rptlab/reportlab)を使用してプリンタに接続するものですが、これは現在のものよりはるかに複雑です。 – thebjorn

+0

ありがとうございました。私はまだ別の設定をしようとしていますが、私が間違いなくあなたが今述べたものを見ていきます。 – Soichiro

+0

多分これは役に立ちます.. ..? https://forums.anandtech.com/threads/command-line-image-printing-in-linux.739845/ – thebjorn

答えて

0

次おかげで

os.system("lp -o fit-to-page -o orientation-requested=3 -o media=Custom.58x210mm logo.png") 

は、皆をありがとうthebjornすることです。

関連する問題