diff options
author | xuri <xuri.me@gmail.com> | 2021-01-17 01:06:08 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2021-01-17 01:06:08 +0800 |
commit | b260485f29038ca8df9993edb1c021672b3df7e4 (patch) | |
tree | d0c1307a6262461d8405aa6537aa3a45a19fb72f /sheet_test.go | |
parent | 054bb9f0612ab7bd5836c3817d105a9b0c9e6059 (diff) |
support to set print black and white and specified the first printed page number
Diffstat (limited to 'sheet_test.go')
-rw-r--r-- | sheet_test.go | 32 |
1 files changed, 21 insertions, 11 deletions
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)}, |