smbj icon indicating copy to clipboard operation
smbj copied to clipboard

[Question] How to pass the filename in the PrinterShare?

Open ramkumarkb opened this issue 3 years ago • 3 comments

Hello,

First of all, thank you for this awesome library !

I am trying to figure out if there is a way to pass filename in the PrinterShare -See below the sample code (in Kotlin) - which connects to the printer and sends the data - but the file name appears as Remote Downlevel Document in the Printer Queue.

Any tips or pointer will be super helpful.

fun printerConnection() {
        val smbConfig = SmbConfig
                .builder()
                .withMultiProtocolNegotiate(true)
                .withTransportLayerFactory(AsyncDirectTcpTransportFactory())
                .withSigningRequired(true).build()
        val client = SMBClient(smbConfig)
        val host = "printserverhost"
        client.connect(host).use { connection ->
            val ac = AuthenticationContext("loginID", "password".toCharArray(), "mydomain.net")
            val session: Session = connection.authenticate(ac)
            val command = Files.readAllBytes(Paths.get("C:/data/test.pdf"))
            (session.connectShare("PrinterName-PCL") as PrinterShare).use { share ->
                val stream: InputStream = ByteArrayInputStream(command)
                share.print(stream)
            }
        }
    }

ramkumarkb avatar May 25 '21 13:05 ramkumarkb

@ramkumarkb Unlikely to do without active support from the library. After checking out other similar sources and the documentation, when the printer request is sent, SMB_COM_OPEN_PRINT_FILE, that can contain the name (although the other side is at liberty to use it or not).

deakjahn avatar Nov 25 '21 20:11 deakjahn

I think all the SMB_COM_* are for SMBv1.

hierynomus avatar Nov 25 '21 20:11 hierynomus

Could well be. But then, can we specify it somehow? Not that it's that terribly important but it would be a nice touch. :-)

deakjahn avatar Nov 25 '21 23:11 deakjahn