Closed paulschmeida closed 2 years ago
I guess that first, you can try to use the low-level smbprotocol code to open the printer and write the file to it.
For sending a file to a printer, the application opens the root of a print share, writes data, and closes the file. The semantics and parameters are the same as specified in section 3.2.4.3, except that TreeConnect.ShareName will be the name of a printer share, and the share relative path MUST be NULL.
I have never used SMB for printing... so I don't know the details.
Yea this is theoretically possible and based on the docs you might just be able to do
import smbclient
with smbclient.open_file(r"\\server\printer_share", mode="xb", buffering=0) as fd:
fd.write(file_bytes)
But even then I've never tested this or are sure if it will work.
Hi, just wanted to confirm that it works exactly as you described @jborean93 :) I can even skip having the files on the filesystem and just pass io.BytesIO()
objects to it.
Hi. I am trying to figure out how to replicate this functionality of smbclient:
smbclient -U username \\\\server\\printer_share -c "print file.txt"
I've looked through files but I can't figure out how to do it with this library and I would like to avoid using subprocess for compatibility reasons.