github.com/pdfcpu/pdfcpu@v0.11.1/pkg/api/test/rotate_test.go (about)

     1  /*
     2  Copyright 2020 The pdf Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8  	http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package test
    18  
    19  import (
    20  	"path/filepath"
    21  	"testing"
    22  
    23  	"github.com/pdfcpu/pdfcpu/pkg/api"
    24  )
    25  
    26  func TestRotate(t *testing.T) {
    27  	msg := "TestRotate"
    28  	fileName := "Acroforms2.pdf"
    29  	inFile := filepath.Join(inDir, fileName)
    30  	outFile := filepath.Join(outDir, fileName)
    31  
    32  	// Rotate all pages of inFile, clockwise by 90 degrees and write the result to outFile.
    33  	if err := api.RotateFile(inFile, outFile, 90, nil, nil); err != nil {
    34  		t.Fatalf("%s: %v\n", msg, err)
    35  	}
    36  
    37  	// Rotate the first page of inFile by 180 degrees.
    38  	// If you want to modify the original file, pass an empty string for outFile.
    39  	inFile = outFile
    40  	if err := api.RotateFile(inFile, "", 180, []string{"1"}, nil); err != nil {
    41  		t.Fatalf("%s: %v\n", msg, err)
    42  	}
    43  }