Giter Site home page Giter Site logo

gmuth / ipp-samples Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 4.0 5.51 MB

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

Kotlin 71.94% Java 27.68% Shell 0.38%
ipp-protocol cups java kotlin printing bonjour-discovery airprint

ipp-samples's Introduction

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

ipp-samples's People

Contributors

gmuth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ipp-samples's Issues

can't no find contentType

I used HP PageWide MFP P57750 - J9V82D run this java samples ๏ผŒ can't find contentType in IppClient.kt:102 ,why?

what should I do?

Exception in thread "main" java.lang.NullPointerException
	at de.gmuth.ipp.client.IppClient.exchange(IppClient.kt:102)
	at de.gmuth.ipp.client.IppClient.exchangeSuccessful(IppClient.kt:67)
	at de.gmuth.ipp.client.IppPrinter.exchangeSuccessful(IppPrinter.kt:250)
	at de.gmuth.ipp.client.IppPrinter.getPrinterAttributes(IppPrinter.kt:140)
	at de.gmuth.ipp.client.IppPrinter.getPrinterAttributes$default(IppPrinter.kt:138)
	at de.gmuth.ipp.client.IppPrinter.updateAllAttributes(IppPrinter.kt:144)
	at de.gmuth.ipp.client.IppPrinter.<init>(IppPrinter.kt:28)
	at de.gmuth.ipp.client.IppPrinter.<init>(IppPrinter.kt:24)
	at de.gmuth.ipp.client.IppPrinter.<init>(IppPrinter.kt:37)
	at ipp.PrinterAttributes.main(PrinterAttributes.java:9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.