smbj
smbj copied to clipboard
[Question] How to pass the filename in the PrinterShare?
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 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).
I think all the SMB_COM_*
are for SMBv1.
Could well be. But then, can we specify it somehow? Not that it's that terribly important but it would be a nice touch. :-)