-
Notifications
You must be signed in to change notification settings - Fork 796
Print a PDF to a physical printer #320
Comments
I think maybe the ghostscript features are needed to rasterise the pdf for viewing. But it seems it can also open the printer dialogue and send the pdf to the printer ? |
You're right -- physical printing is not a part of PDF production. If you want a solution for the Windows platform, the github.com/alexbrainman/printer project may be what you need. On Linux and Mac, I would look into Samba. |
The Alexbrainman only prints text, not PDF. I looked at his lib and spoke to him about about it already. Seems like a dead end.
Cant use this becaue i cant assume they have samba. It imposses too much on the users to have to install Samba. The onyl way to do it properly is to open the native Print Preview dialog. Trying to work out how to tap into this native stuff on Windows and Mac and linux. |
Good point. This seems to point to some cross-platform GUI framework that has access to the native print dialog and can execute the PDF generation application. This application, which imports gofpdf, would accept parameters that would drive the PDF process. |
yep thats basically it. |
@joeblew99 one option (if you're either on linux/osx or dealing with networked printers) is an ipp client like https://github.com/phin1x/go-ipp you'd have to build the print dialog yourself though |
@jacobalberty thanks will try it now. |
I got this working with go-ipp so figured I'd post enough of my code here to help anyone else . type IPPDriver struct {
bytes.Buffer
printer string
server string
port int
user string
password string
}
func (d *IPPDriver) Print(name string) (int, error) {
doc := ipp.Document{
Document: d,
Size: d.Buffer.Len(),
Name: name,
MimeType: "application/pdf",
}
ippc := ipp.NewIPPClient(d.server, d.port, d.user, d.password, true)
return ippc.PrintJob(doc, d.printer, map[string]interface{}{})
} |
i looked here and only found HP printer supported: https://www.pwg.org/dynamo/eveprinters.php |
@joeblew99 cups as of 2.3 is deprecating printer drivers to rely on IPPE the logic being most printers sold after 2010 support the IPPE standard. So virtually any network printer should support IPP, not all will support PDF input I think I have a few older printers at work that claim not to support PDF. I'm doing all my printing through cups right now though which can act as an IPP endpoint for any printer cups supports (even with 2.3 printer drivers still work they're just deprecated) |
Wondering if there is any information about how to managing printing on desktops in golang.
This is the sequence I am trying to achieve
After the user has selected a pdf template and my code has merged data into the pdf I want to let the user print it.
Opens the print dialogue for the OS.
User selects printer, orientation, paper side.
The orientation and paper size is used to defender the pdf correctly.
Then user is show new pdf
Then user confirms and prints
Then system send to print spooler.
Am looking for tips about how to access these OS specific APIs.
It's not PDF related but I would think others may find this useful.
Hoping I can work this out and put into contribution repo
The text was updated successfully, but these errors were encountered: