goprint icon indicating copy to clipboard operation
goprint copied to clipboard

Problem with PDF printing

Open 3lf opened this issue 2 years ago • 2 comments

Hi, thanks for good library. i have issue with print pdf. when i print pdf, it prints source. for example: %PDF-1.4 %���� 1 0 obj <</Creator (Mozilla/5.0 \(X11; Linux x86_64\) AppleWebKit/537.36 \(KHTML, like Gecko\) Chrome/99.0.4844.82 Safari/537.36) /Producer (Skia/PDF m99) /CreationDate (D:20220406213418+00'00') /ModDate (D:20220406213418+00'00')>> endobj 3 0 obj <</ca 1 /BM /Normal>> endobj 5 0 obj <</Type /XObject /Subtype /Image /Width 1107 /Height 192 /ColorSpace /DeviceGray /BitsPerComponent 8 /Filter /DCTDecode /ColorTransform 0 /Length 4524>> stream ����^@^PJFIF^@^A^A^@^@^A^@^A^@^@��^@C^@^P^K^L^N^L ^P^N^M^N^R^Q^P^S^X(^Z^X^V^V^X1#%^](:3=<9387@H\N@DWE78PmQW_bghg>Mqypdx\egc��^@^K^H^@�^DS^A^A^Q^@��^@^[^@^A^@^B^C^A^A^@^@^@^@^@^@^@^@^@^@^@^A^E^B^> ^T(P�B�

can you help me?

3lf avatar Apr 06 '22 21:04 3lf

i used sample code:

package main

import (
	"log"
	"github.com/jadefox10200/goprint"
)

func main() {

	printerName, _ := goprint.GetDefaultPrinterName()

	//open the printer
	printerHandle, err := goprint.GoOpenPrinter(printerName)	
	if err != nil {log.Fatalln("Failed to open printer")}
	defer goprint.GoClosePrinter(printerHandle)
	
	filePath := "C:/test/myPDF.pdf"
		
	//Send to printer:		
	err = goprint.GoPrint(printerHandle, filePath)
	if err != nil {	log.Fatalln("during the func sendToPrinter, there was an error") }


}

3lf avatar Apr 06 '22 21:04 3lf

Looks like it's printing the raw code of the PDF. What printer are you using? This package is VERY basic and sends the data to the printer raw. This means your printer must be able to understand the PDF language.

jadefox10200 avatar Apr 30 '22 01:04 jadefox10200