/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

Configure Gradle for use with Github Packages. Use this github package of the project as maven repo. You can access the repo with any github account.

repositories {
    jcenter()
    maven {
      url = uri("https://maven.pkg.github.com/gmuth/ipp-client-kotlin")
      credentials {
          // configure gpr.user and gpr.token in ~/.gradle/gradle.properties
          // gpr.user=yourname
          // gpr.token=yourtoken
          username = project.findProperty("gpr.user") as String?
          password = project.findProperty("gpr.token") as String?
      }
    }
}

Add dependency:

    implementation("de.gmuth.ipp:ipp-client-kotlin:1.9")
or  implementation("de.gmuth.ipp:ipp-client-kotlin:2.0-SNAPSHOT")