1

Python3.4 では、次のコードを使用して、要求ライブラリを使用して Web サイトから PDF を印刷しています。

with open(temp_pdf_file, 'wb') as handle:
   response = requests.get(html.unescape(message['body']), stream=True)
   for block in response.iter_content(1024):
       handle.write(block)
cmd = '/usr/bin/lpr -P {} {}'.format(self.printer_name,temp_pdf_file)
print(cmd)
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
stdout, stderr = proc.communicate()
exit_code = proc.wait()

一時ファイルの保存をスキップして、プリンターに直接ストリーミングする方法はありますか?

4

1 に答える 1