jadefox10200 / goprint

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

RAW type error use XPS_PASS OPTION #2

Closed robtrooper closed 2 years ago

robtrooper commented 4 years ago

Using Window 10 64bit pro i couldn't get anything to print to my network Brother DCP-9020CDW. But i changed this line pDatatype: &(syscall.StringToUTF16("RAW"))[0], to pDatatype: &(syscall.StringToUTF16("XPS_PASS"))[0],

and it worked.

amvicc commented 4 years ago

This works for Ricoh MP C2051

frederikhors commented 3 years ago

Same here.

If I generate a pdf with https://github.com/johnfercher/maroto (which is using https://github.com/jung-kurt/gofpdf underneath) and save it to "C:/test/myPdf.pdf" I get no error but it doesn't print.

If I change that line as @robtrooper suggests the print starts but no pdf is printed, only strange characters.

I'm stucked.

jadefox10200 commented 3 years ago

Same here.

If I generate a pdf with https://github.com/johnfercher/maroto (which is using https://github.com/jung-kurt/gofpdf underneath) and save it to "C:/test/myPdf.pdf" I get no error but it doesn't print.

If I change that line as @robtrooper suggests the print starts but no pdf is printed, only strange characters.

I'm stucked.

This is possibly an issue with the printer. Which printer are you using? This code is very basic and so it assumes the printer understands the PDF language.

jadefox10200 commented 3 years ago

Using Window 10 64bit pro i couldn't get anything to print to my network Brother DCP-9020CDW. But i changed this line pDatatype: &(syscall.StringToUTF16("RAW"))[0], to pDatatype: &(syscall.StringToUTF16("XPS_PASS"))[0],

and it worked.

Ok. So, today I had access to a printer and made some changes. Namely, the Print() function should now get the dataType from the printer itself. However, all the printers I have access to use the "RAW" option. Please try this out for yourself if you have an XPS_PASS supported printer.

To check this out for sure, run the following commands with the new package:

hPrinter, err := OpenPrinter(printerName)
ptr2, err := hPrinter.GetPrinter2()
dataType := ptr2.GetDataType()
fmt.Printf("Printer data type: %s", dataType)

This should print the printer data type to the console and therefore no longer need to be hardcoded in as a type. Please confirm if this works. Thanks.

jadefox10200 commented 3 years ago

Same here.

If I generate a pdf with https://github.com/johnfercher/maroto (which is using https://github.com/jung-kurt/gofpdf underneath) and save it to "C:/test/myPdf.pdf" I get no error but it doesn't print.

If I change that line as @robtrooper suggests the print starts but no pdf is printed, only strange characters.

I'm stucked.

When u make a pdf using gofpdf, you'll need to set the SetCompression() method to flase like so:

pdf.SetCompression(false)

If the pdf is compressed ur printer will not be able to read it.

jairforero commented 3 years ago

Me print content file ascii as txt file, please help

jadefox10200 commented 2 years ago

This appears handled as no further data from robtrooper.