Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get all printers using IPP #27

Open
abdul-creator opened this issue Oct 9, 2022 · 1 comment
Open

Get all printers using IPP #27

abdul-creator opened this issue Oct 9, 2022 · 1 comment

Comments

@abdul-creator
Copy link

Hello,
I am trying to

  • get all the printers on cups server.
  • get the state of printer.
  • if state = pause then resume or resume all.
    Would be grateful if get example. I tried IPP package but failed to import package and use the func get printers.
    Thanks
@abdul-creator
Copy link
Author

abdul-creator commented Oct 9, 2022

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

@abdul-creator abdul-creator changed the title Get all printer using IPP Get all printers using IPP Oct 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant