/ipp-samples

ipp-client use cases written in java or kotlin with build support for gradle and maven, bonjour discovery

Primary LanguageKotlin

gradle build maven build

ipp-samples

Sample code written in java and kotlin using my ipp-client library.

Bonjour Discovery

Use jmDNS to discover printers via Bonjour including AirPrint compatible printers.

val jmDns = JmDNS.create()
jmDns.list("_ipp._tcp.local.").forEach {
    val printerName = it.name
    val printerUri = with(it) { URI.create("ipp://$server:$port/${getPropertyString("rp")}") }
    val ippPrinter = IppPrinter(printerUri)
    println("* $printerName")
    println("  $printerUri")
    println("  $ippPrinter")
}
jmDns.close()

Java

Print a pdf file and wait for the printer to finish.

// initialize printer connection and show printer attributes
IppPrinter ippPrinter=new IppPrinter("ipp://colorjet.local/ipp/printer");
  ippPrinter.logDetails();

// print file
File file=new File("my-document.pdf");
IppJob job=ippPrinter.printJob(
  file,
  documentFormat("application/pdf"),
  jobName(file.getName()),
  IppColorMode.Monochrome
);
job.logDetails();

// wait until printer has completed the job
job.waitForTermination();
job.logDetails();

Dependency

    implementation("de.gmuth:ipp-client:2.3")