All Projects → phin1x → Go Ipp

phin1x / Go Ipp

Licence: apache-2.0
Pure Go IPP library

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Labels

Projects that are alternatives of or similar to Go Ipp

iOS-AirPrint-for-Mac
enable iOS Airprint Sharing on Mac OS
Stars: ✭ 24 (-40%)
Mutual labels:  printing
ipp.rs
IPP protocol implementation for Rust
Stars: ✭ 24 (-40%)
Mutual labels:  printing
Gutenberg
Modern framework to print the web correctly.
Stars: ✭ 4,425 (+10962.5%)
Mutual labels:  printing
chrome-raw-print
Chrome app to enable raw printing from a browser
Stars: ✭ 57 (+42.5%)
Mutual labels:  printing
ngx-print
🖨️ A plug n' play Angular (2++) library to print your stuff
Stars: ✭ 124 (+210%)
Mutual labels:  printing
Task-Card-Creator
Small tool for printing task cards used for a Scrum board. Your physical Scrum board will look fantastic. Supports Team Foundation Server and Azure DevOps.
Stars: ✭ 25 (-37.5%)
Mutual labels:  printing
jipp
A Java implementation of IPP
Stars: ✭ 97 (+142.5%)
Mutual labels:  printing
Mapbox Gl Print Export For Port
Print/Export for Mapbox GL
Stars: ✭ 14 (-65%)
Mutual labels:  printing
press-ready
🚀 Make your PDF press-ready PDF/X-1a.
Stars: ✭ 56 (+40%)
Mutual labels:  printing
One File Pdf
A minimalist Go PDF writer in 1982 lines. Draws text, images and shapes. Helps understand the PDF format. Used in production for reports.
Stars: ✭ 429 (+972.5%)
Mutual labels:  printing
escpos-tools
Utilities to read ESC/POS print data
Stars: ✭ 145 (+262.5%)
Mutual labels:  printing
barcode
No description or website provided.
Stars: ✭ 27 (-32.5%)
Mutual labels:  printing
ipp-client-kotlin
A client implementation of the ipp protocol written in kotlin
Stars: ✭ 25 (-37.5%)
Mutual labels:  printing
paper-store
Cold store small files on paper as QR codes -- PGP keys, Bitcoin keys, Tox keys or any other small files in general.
Stars: ✭ 28 (-30%)
Mutual labels:  printing
Pagedown
Paginate the HTML Output of R Markdown with CSS for Print
Stars: ✭ 619 (+1447.5%)
Mutual labels:  printing
mini-map-maker
A tool for automatically generating 3D printable STLs from freely available lidar scan data.
Stars: ✭ 51 (+27.5%)
Mutual labels:  printing
carto-print
A Python module to export images at any resolution, size and bounding box from a CARTO named map:
Stars: ✭ 18 (-55%)
Mutual labels:  printing
Tree printer
A Java class for printing binary trees as ASCII text
Stars: ✭ 20 (-50%)
Mutual labels:  printing
Printthis
jQuery printing plugin; print specific elements on a page
Stars: ✭ 902 (+2155%)
Mutual labels:  printing
printnode-integration
Smarting Printing from Frappe using Print Node API
Stars: ✭ 21 (-47.5%)
Mutual labels:  printing

go-ipp

Version Documentation Go Report Card Licence

Go Get

To get the package, execute:

go get -u github.com/phin1x/go-ipp

Features

  • basic ipp 2.0 compatible Client
  • extended client for cups server
  • create custom ipp requests
  • parse ipp responses and ipp control files

Example

Print a file with the ipp client

package main

import "github.com/phin1x/go-ipp"

func main() {
    // create a new ipp client
    client := ipp.NewIPPClient("printserver", 631, "user", "password", true)
    // print file
    client.PrintFile("/path/to/file", "my-printer", map[string]interface{}{})
}

Craft and send a custom request


package main

import "github.com/phin1x/go-ipp"

func main() {             
    // define a ipp request
    req := ipp.NewRequest(OperationGetJobs, 1)
    req.OperationAttributes[ipp.AttributeWhichJobs] = "completed"
    req.OperationAttributes[ipp.AttributeMyJobs] = myJobs
    req.OperationAttributes[ipp.AttributeFirstJobID] = 42
    req.OperationAttributes[ipp.AttributeRequestingUserName] = "fabian"
    
    // encode request to bytes
    payload, err := req.Encode()
    if err != nil {
        panic(err)
    }
    
    // send ipp request to remote server via http
    httpReq, err := http.NewRequest("POST", "http://my-print-server:631/printers/my-printer", bytes.NewBuffer(payload))
    if err != nil {
        panic(err)
    }
    
    // set ipp headers
    httpReq.Header.Set("Content-Length", len(payload))
    httpReq.Header.Set("Content-Type", ipp.ContentTypeIPP)
    
    httpClient := &http.Client()
    httpResp, err := httpClient.Do(httpReq)
    if err != nil {
        panic(err)
    }
    defer httpResp.Body.Close()
    
    // response must be 200 for a successful operation
    // other possible http codes are: 
    // - 500 -> server error
    // - 426 -> sever requests a encrypted connection
    // - 401 -> forbidden -> need authorization header or user is not permitted
    if httpResp.StatusCode != 200 {
        panic("non 200 response from server")
    }
    
    // decode ipp response
    resp, err := ipp.NewResponseDecoder(httpResp.Body).Decode(nil)
    if err != nil {
        panic(err)
    }
    
    // check if the response status is "ok"
    if resp.StatusCode == ipp.StatusOk {
        panic(resp.StatusCode)
    }
    
    // do something with the returned data
    for _, job := resp.JobAttributes {
        // ...
    }
}

Licence

Apache Licence Version 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].