alexbrainman / printer

Windows printing
BSD 3-Clause "New" or "Revised" License
227 stars 80 forks source link

Status "printing" but not printing after using the library #24

Open Feggah opened 2 years ago

Feggah commented 2 years ago

The problem

I'm facing a problem where I'm trying to send a job to print a RAW file to the printer. The job is actually created in the printer jobs list, but the status keeps "Printing" but don't actually start printing.

I thought it could be a misconfiguration on the printer itself, but when I try to print any other document using other program, it prints normally.

What could be done

I don't know if anyone has experienced that and how have you overcome this, any tips would be appreciated. You can check my code at Feggah/calculator/printer/printer.go

alexbrainman commented 2 years ago

@Feggah

Your code looks reasonable. I don't know what your problem is.

I use this command line program

https://github.com/alexbrainman/printer/tree/master/cmd/print

to print raw file data to my printer. You could try my program to see if it makes any difference.

Alex

Feggah commented 2 years ago

I tried with your program and it didn`t work as well... see the print below image

It works if I use "Microsoft XPS Document Writer" as target printer, but if I try to use a real one, it only enqueues the job (status: Printing) but doesn't actually print it. Does it works normally for you?

alexbrainman commented 2 years ago

I tried with your program and it didn`t work as well... see the print below

I do not know what the problem is.

Does it works normally for you?

It used to work with variety of OS and printers. I just tried it with current version of Windows 10 and my specific printer, and it does not work.

Sorry.

Alex

Feggah commented 2 years ago

No problem, Alex!

The problem that you faced with your printer is the same as mine? The job is enqueued, the status changes to "Printing", but it never prints?

alexbrainman commented 2 years ago

The problem that you faced with your printer is the same as mine?

I tried using github.com/alexbrainman/printer/cmd/print program to print small text file to my default printer.

The program runs successfully without any errors. But then I get this error message in the corner of my desktop

image

And nothing is printed on the printer.

And my printer queue looks like that

image

And I had to manually delete my print job to clear the queue.

I also run this test in github.com/alexbrainman/printer directory:

go test -run=TestPrinter 

The test passes.

And nothing prints again.

I see no Windows error messages this time.

My print job is still stuck in the queue

image

And I still have to manually delete the job to clear the queue.

I spent some time trying to google for some examples of code similar to mine (in any programming language). And they look exactly the same - they use the same API in a same way. Including Microsoft own examples:

https://docs.microsoft.com/en-us/windows/win32/printdocs/sending-data-directly-to-a-printer

https://docs.microsoft.com/en-us/windows/win32/printdocs/startdocprinter

So I don't know what I am doing wrong.

If you can point me to a source code of any program that works for you, I am happy to spent more time on this.

Alex

Feggah commented 2 years ago

Thanks for spending the time debugging it, Alex. I would love to help you more with this but I have no experience with this API and your library looks fine to me, I don't know what is missing 🤔

I did a temporary workaround for this error for now, it isn't the best solution but it works. I used notepad as an intermediary to send a file to my printer, you can check the code in this gist.

What do you think about this temporary solution?

alexbrainman commented 2 years ago

What do you think about this temporary solution?

Looks good to me. Assuming your program is allowed to use notepad program.

Alex

davilatk commented 1 year ago

I have the same problem