Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use this library to search and print to wifi printers (android) #105

Open
IvanJanjik opened this issue Nov 16, 2020 · 2 comments
Open

Comments

@IvanJanjik
Copy link

IvanJanjik commented Nov 16, 2020

Hi,

I need to create an android application, with basic functionality that when the user taps print(UI button) the app should automatically send print requests to some printer, with no user input in printer selection at that exact moment and no print preview should be displayed. There could be printer selection(configuration) but it should not bother the user every time it wants to print (it should ask the user for printer selection only one time or occasionally).

So after some research, I found out about this library and it seems like the thing I need. I tried to implement it but no luck, I don't know how to use it to scan for available printers and their Uri.

I get this error trying to send print to HPLaserJetP1102W :
java.net.SocketTimeoutException: connect timed out
W/System.err: at com.ivanjanikj.bistroprinting.HttpIppClientTransport.sendData(HttpIppClientTransport.java:42)

I have created HttpIppClientTransport exactly like this example -> https://github.com/HPInc/jipp/blob/master/sample/jprint/src/main/java/sample/HttpIppClientTransport.javri
I think the problem is that I'm using the wrong Uri when creating this code block
{
URI uri = URI.create("http://192.168.1.100:631/ipp/print");
IppPacket printRequest = IppPacket.printJob(uri)
.putOperationAttributes(documentFormat.of("application/pdf")))
.build();
transport.sendData(uri, new IppPacketData(printRequest, new FileInputStream(inputFile)));
}

My question is: How to find the URI of every WIFI printer using this library, is there some method that I can use, that I'm not aware of?

Thank you

@GladeDiviney
Copy link
Collaborator

GladeDiviney commented Nov 16, 2020

This library doesn't implement discovery at present. In Android you can use JMDNS (a separate Java library) or if you are targeting modern Android OS only, NsdManager.

I'm leaving this open because implementing discovery using either method would be a good addition.

@gmuth
Copy link

gmuth commented Apr 12, 2021

This demonstrates how to discover ipp printers using bonjour/zeroconf:
https://github.com/gmuth/ipp-samples/blob/main/src/main/kotlin/mdns/DiscoverIppPrinters.kt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants