From 31b9eb5010449addc82b83062daaf9d53522d280 Mon Sep 17 00:00:00 2001 From: Fabian <-> Date: Sat, 28 Mar 2020 00:32:25 +0100 Subject: [PATCH] moved the PrintTestPage Function to the cups client --- cups-client.go | 26 +++++++++++++++++++++++++- ipp-client.go | 21 --------------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/cups-client.go b/cups-client.go index 519ff07..74ff7b1 100644 --- a/cups-client.go +++ b/cups-client.go @@ -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", + }) +} diff --git a/ipp-client.go b/ipp-client.go index a5d7008..51885c3 100644 --- a/ipp-client.go +++ b/ipp-client.go @@ -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))