moved the PrintTestPage Function to the cups client

This commit is contained in:
Fabian 2020-03-28 00:32:25 +01:00
parent 03317e6333
commit 31b9eb5010
2 changed files with 25 additions and 22 deletions

View File

@ -1,6 +1,9 @@
package ipp
import "strings"
import (
"bytes"
"strings"
)
type CUPSClient struct {
*IPPClient
@ -269,3 +272,24 @@ func (c *CUPSClient) GetClasses(attributes []string) (map[string]Attributes, err
return printerNameMap, nil
}
// PrintTestPage prints a test page of type application/vnd.cups-pdf-banner
func (c *CUPSClient) PrintTestPage(printer string) (int, error) {
testPage := new(bytes.Buffer)
testPage.WriteString("#PDF-BANNER\n")
testPage.WriteString("Template default-testpage.pdf\n")
testPage.WriteString("Show printer-name printer-info printer-location printer-make-and-model printer-driver-name")
testPage.WriteString("printer-driver-version paper-size imageable-area job-id options time-at-creation")
testPage.WriteString("time-at-processing\n\n")
return c.PrintDocuments([]Document{
{
Document: testPage,
Name: "Test Page",
Size: testPage.Len(),
MimeType: MimeTypePostscript,
},
}, printer, map[string]interface{}{
AttributeJobName: "Test Page",
})
}

View File

@ -389,27 +389,6 @@ func (c *IPPClient) HoldJobUntil(jobID int, holdUntil string) error {
return err
}
// PrintTestPage prints a test page of type application/vnd.cups-pdf-banner
func (c *IPPClient) PrintTestPage(printer string) (int, error) {
testPage := new(bytes.Buffer)
testPage.WriteString("#PDF-BANNER\n")
testPage.WriteString("Template default-testpage.pdf\n")
testPage.WriteString("Show printer-name printer-info printer-location printer-make-and-model printer-driver-name")
testPage.WriteString("printer-driver-version paper-size imageable-area job-id options time-at-creation")
testPage.WriteString("time-at-processing\n\n")
return c.PrintDocuments([]Document{
{
Document: testPage,
Name: "Test Page",
Size: testPage.Len(),
MimeType: MimeTypePostscript,
},
}, printer, map[string]interface{}{
AttributeJobName: "Test Page",
})
}
// TestConnection tests if a tcp connection to the remote server is possible
func (c *IPPClient) TestConnection() error {
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", c.host, c.port))