Git Product home page Git Product logo

ipp-printjob-kotlin's Introduction

ipp-printjob-kotlin

A minimal client implementation of the ipp protocol (100 lines) written in kotlin for the jvm.

Java CI with Gradle

General

The printjob source code should be useful for use cases of driverless printing. Especially automated processes without user interaction should benefit from simple solutions like this. This code is not and will never become a full-fledged ipp implementation. I provide more control over print jobs, monitoring of printers and print jobs in my other project ipp-client-kotlin.

Distribution

For the impatient binary releases are provided. Directory demo also contains the printjob.jar and a test script called go that submits a blank PDF to Apple's Printer Simulator. To avoid real printing, registered Apple developers can download Additional Tools for Xcode containing the Printer Simulator.

Usage

The tool takes two arguments: printer-uri and file-name. If you don't know the printer uri try ippfind.

java -jar printjob.jar ipp://colorjet:631/ipp/printer A4-blank.pdf

send ipp request to ipp://colorjet:631/ipp/printer
ipp version 1.1
ipp response status: 0000
group 01
   attributes-charset (47) = utf-8
   attributes-natural-language (48) = en
group 02
   job-uri (45) = ipp://colorjet:631/jobs/352
   job-id (21) = 352
   job-state (23) = 3
   job-state-reasons (44) = none
group 03

The equivalent kotlin code is:

printJobStreamingVersion(
    URI.create("ipp://colorjet:631/ipp/printer"),
    FileInputStream(File("A4-blank.pdf"))
)

Document Format

The operation attributes group does not include a value for document-format by default. This should be equivalent to application/octet-stream indicating the printer has to auto sense the document format. You have to make sure the printer supports the document format you send - PDF is usually a good option. If required by your printer, you can set the document format programmatically by adding it e.g. after the printer-uri attribute.

writeAttribute(0x49, "document-format", "application/pdf")

Issues

If you use an unsupported printer-uri you will get a response similar to this one:

send ipp request to ipp://localhost:8632/ipp/norona
ipp version 1.1
ipp status 0400
group 01
   attributes-charset (47) = utf-8
   attributes-natural-language (48) = en
   status-message (41) = Bad printer-uri "ipp://localhost:8632/ipp/norona".
group 03

You can use ippfind or dns-sd -Z _ipp._tcp (look at the rp value) to discover your printer's uri. If you have other issues contact me.

Two implementations: Intermediate ByteArray and Streaming

IPP messages are binary encoded requests and responses that are being transmitted via HTTP POST. The ByteArrayVersion uses a ByteArray as intermediate buffer structure to temporarily save the IPP request and response. Newbies will find this easier to understand because encoding, message exchange and decoding are nicely separated.

In the StreamingVersion the connection handling embraces the encoding and decoding fragments.

Build

To build printjob.jar into build/libs you need an installed JDK.

./gradlew

Community

I'd be happy to see this minimal ipp implementation being ported to all kinds of programming languages. On request I'll explain developers without experience in jvm based languages what the jvm runtime library is used for.

ipp-printjob-kotlin's People

Contributors

gmuth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.