jadefox10200 / goprint

Attempt at a windows printer in golang
MIT License
112 stars 28 forks source link

Error while running the sample code provided #9

Closed GideonStruts closed 2 years ago

GideonStruts commented 2 years ago

Details of the error:

# github.com/jadefox10200/goprint ..\..\pkg\mod\github.com\jadefox10200\goprint@v0.0.0-20211114090828-980e534e475a\out.go:27:7: cannot use _ as value ..\..\pkg\mod\github.com\jadefox10200\goprint@v0.0.0-20211114090828-980e534e475a\out.go:34:11: cannot assign uintptr to _ in multiple assignment ..\..\pkg\mod\github.com\jadefox10200\goprint@v0.0.0-20211114090828-980e534e475a\out.go:34:11: cannot assign syscall.Errno to _ in multiple assignment ..\..\pkg\mod\github.com\jadefox10200\goprint@v0.0.0-20211114090828-980e534e475a\out.go:40:12: cannot assign uintptr to _ in multiple assignment

jadefox10200 commented 2 years ago

cannot assign uintptr to _ in multiple assignment

That's interesting. It's been a while since I used the package myself and haven't used a windows machine in some time. I'm hoping someone can help with this issue as I do not have a windows set up to test this in at this moment. The odd thing is that your errors are basically telling you that they will not accept blank identifiers. The file out.go was machine generated.

However, I believe the issue is a pretty dumb one on my part. I believe the wrong main.go file is on github.com and so doesn't match the out.go file. I created a new branch name 'outFix'. Please download the main.go file from that branch and test newly. If that fails, please then run 'go generate' newly to create a new out.go file.

Let me know what you find. Thank you.

jadefox10200 commented 2 years ago

So, I've made some changes and generated a new out2.go file. I built this on a windows system so it should work but do not have access to a printer currently. Please try this and let me know. Again, download this from the outFix branch, not the master branch. Thank you

GideonStruts commented 2 years ago

Here is the result after running the example in the outFix branch.

`panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x46 pc=0xd205e0]

goroutine 1 [running]: goprint.(*PRINTER_INFO_9).PrintDevMode(0xc000014330) C:/Users/hp/go/src/goprint/main.go:531 +0x20 main.main() C:/Users/hp/go/src/goprint/examples/printer.go:42 +0xee exit status 2`

it's failing at this function: ptr9.PrintDevMode()

jadefox10200 commented 2 years ago

It should have printed other data before it gave that panic. Such as: open printer: with a message. In reality, the example that is in that folder is simply some test code I wrote some time ago. prtr9.PrintDevMode() doesn't actually do anything other than print some data to the screen. However, if you are getting a panic, it means the data field wasn't set. I am uploading another example: printer5.go in the outFix branch. Please give this a shot and report the entire output from the terminal. Thanks.

GideonStruts commented 2 years ago

Thanks for the update. Here is the full console output after pulling the latest change; `go run printer.go OneNote for Windows 10 :: :: Microsoft.Office.OneNote_16001.14326.20588.0_x64__8wekyb3d8bbwe_microsoft.onenoteim_S-1-5-21-1717744398-1987311770-1331255471-1001 PDFCreator :: :: pdfcmon PDF Architect 8 :: :: PDFArchitect8_Port: Microsoft XPS Document Writer :: :: PORTPROMPT: Microsoft Print to PDF :: :: PORTPROMPT: Fax :: :: SHRFAX: panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x1 addr=0x5e pc=0x320552]

goroutine 1 [running]: goprint.(*DevMode).SetDuplex(...) C:/Users/hp/go/src/goprint/main.go:894 goprint.HANDLE.SetDuplexPrinter9(0x342465, 0x2) C:/Users/hp/go/src/goprint/main.go:504 +0x32 main.main() C:/Users/hp/go/src/goprint/examples/printer.go:45 +0xde exit status 2`

You could use PDFCreator for testing purposes which would simulate the intended effect of printing. If it works well with it, we should be good to print to a hard copy printer.

jadefox10200 commented 2 years ago

That's isn't really the case. A PDF creator isn't a printer. You need to set things differently for that. Are you sending this to an actual physical printer? If not, the DevMode will not populate which is why there are errors.

jadefox10200 commented 2 years ago

This is being closed as this issue is not related to a physical printer and this package was not designed to create PDFs.