Skip to content

Latest commit

 

History

History
56 lines (45 loc) · 1.77 KB

README.md

File metadata and controls

56 lines (45 loc) · 1.77 KB

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")