From b260485f29038ca8df9993edb1c021672b3df7e4 Mon Sep 17 00:00:00 2001 From: xuri Date: Sun, 17 Jan 2021 01:06:08 +0800 Subject: support to set print black and white and specified the first printed page number --- sheet_test.go | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'sheet_test.go') diff --git a/sheet_test.go b/sheet_test.go index 701d824..d68327e 100644 --- a/sheet_test.go +++ b/sheet_test.go @@ -13,15 +13,11 @@ import ( func ExampleFile_SetPageLayout() { f := NewFile() - if err := f.SetPageLayout( "Sheet1", + BlackAndWhite(true), + FirstPageNumber(2), PageLayoutOrientation(OrientationLandscape), - ); err != nil { - fmt.Println(err) - } - if err := f.SetPageLayout( - "Sheet1", PageLayoutPaperSize(10), FitToHeight(2), FitToWidth(2), @@ -35,12 +31,20 @@ func ExampleFile_SetPageLayout() { func ExampleFile_GetPageLayout() { f := NewFile() var ( - orientation PageLayoutOrientation - paperSize PageLayoutPaperSize - fitToHeight FitToHeight - fitToWidth FitToWidth - scale PageLayoutScale + blackAndWhite BlackAndWhite + firstPageNumber FirstPageNumber + orientation PageLayoutOrientation + paperSize PageLayoutPaperSize + fitToHeight FitToHeight + fitToWidth FitToWidth + scale PageLayoutScale ) + if err := f.GetPageLayout("Sheet1", &blackAndWhite); err != nil { + fmt.Println(err) + } + if err := f.GetPageLayout("Sheet1", &firstPageNumber); err != nil { + fmt.Println(err) + } if err := f.GetPageLayout("Sheet1", &orientation); err != nil { fmt.Println(err) } @@ -57,6 +61,8 @@ func ExampleFile_GetPageLayout() { fmt.Println(err) } fmt.Println("Defaults:") + fmt.Printf("- print black and white: %t\n", blackAndWhite) + fmt.Printf("- page number for first printed page: %d\n", firstPageNumber) fmt.Printf("- orientation: %q\n", orientation) fmt.Printf("- paper size: %d\n", paperSize) fmt.Printf("- fit to height: %d\n", fitToHeight) @@ -64,6 +70,8 @@ func ExampleFile_GetPageLayout() { fmt.Printf("- scale: %d\n", scale) // Output: // Defaults: + // - print black and white: false + // - page number for first printed page: 1 // - orientation: "portrait" // - paper size: 1 // - fit to height: 1 @@ -103,6 +111,8 @@ func TestPageLayoutOption(t *testing.T) { container PageLayoutOptionPtr nonDefault PageLayoutOption }{ + {new(BlackAndWhite), BlackAndWhite(true)}, + {new(FirstPageNumber), FirstPageNumber(2)}, {new(PageLayoutOrientation), PageLayoutOrientation(OrientationLandscape)}, {new(PageLayoutPaperSize), PageLayoutPaperSize(10)}, {new(FitToHeight), FitToHeight(2)}, -- cgit v1.2.1