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

StartRawDocument: The data is invalid. #25

Open
palevi67 opened this issue Jun 6, 2024 · 3 comments
Open

StartRawDocument: The data is invalid. #25

palevi67 opened this issue Jun 6, 2024 · 3 comments

Comments

@palevi67
Copy link

palevi67 commented Jun 6, 2024

I'm getting an "The data is invalid" error when calling StartRawDocument ... this was working some weeks ago, so I think it might be caused by some OS upgrade.

¿Any idea?

I'm under W11.

@alexbrainman
Copy link
Owner

¿Any idea?

No idea. Sorry.

Alex

@palevi67
Copy link
Author

I have traced down the program and found the error was generated in the DriverInfo() function. I changed it to the following, and now StartRawDocument() is working again:

// DriverInfo returns information about printer p driver.
func (p *Printer) DriverInfo() (*DriverInfo, error) {
	var needed uint32
	err := GetPrinterDriver(p.h, nil, 8, nil, needed, &needed)
	if err != syscall.ERROR_INSUFFICIENT_BUFFER {
		return nil, err
	}
	b := make([]byte, needed)
	err = GetPrinterDriver(p.h, nil, 8, &b[0], needed, &needed)
	if err != nil {
		return nil, err
	}
	di := (*DRIVER_INFO_8)(unsafe.Pointer(&b[0]))
	return &DriverInfo{
		Attributes:  di.PrinterDriverAttributes,
		Name:        windows.UTF16PtrToString(di.Name),
		DriverPath:  windows.UTF16PtrToString(di.DriverPath),
		Environment: windows.UTF16PtrToString(di.Environment),
	}, nil
}

@alexbrainman
Copy link
Owner

I have traced down the program and found the error was generated in the DriverInfo() function. I changed it to the following, and now StartRawDocument() is working again:

I am glad it works for you.

I still do not understand why it fixes your problem. But I don't use this code myself, so I won't spend time investigating it.

Alex

Tarasa24 added a commit to Juicymo/printer that referenced this issue Jul 29, 2024
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

2 participants