phin1x / go-ipp

Pure Go IPP library
Apache License 2.0
140 stars 36 forks source link

Get all printers using IPP #27

Open abdul-creator opened 2 years ago

abdul-creator commented 2 years ago

Hello, I am trying to

abdul-creator commented 2 years ago

my code for above task so far:

`func main() { // create a new ipp client client := ipp.NewIPPClient("server", 631, "user", "password", true)

err := client.TestConnection()
if err != nil {
    fmt.Printf("%v", err)
} else {
           Get all printers on above server ????
           looping through all the printers
    var res []string
    printer, _ := client.GetPrinterAttributes("1st printer in loop", res)
    for _, atr := range printer {
        for _, nameAtr := range atr {
            if nameAtr.Name == "printer-state-reasons" {
                if xx.Value == "paused" {
                    client.ResumePrinter(printer)
                }
            }
        }
    }
}

}`

// currently I am using chromedp to get all the printers.

func GetPausedPrinter(url string) { ctx, cancel := chromedp.NewContext(context.Background()) defer cancel() ctx, cancel = context.WithTimeout(ctx, 25*time.Second) defer cancel() chromedp.Run(ctx, chromedp.Navigate(url), chromedp.Nodes("/html/body/table/tbody/tr[1]/td/table[2]/tbody/tr/td/a", &HrefNode)) }