Repository navigation
Rotate
huzpsb edited this page Oct 25, 2026
·
1 revision
Rotate selected pages clockwise by a multiple of 90 degrees.
pdfcpu2 rotate [-p pageSelection] inFile rotation [outFile]
rotation: -180 | -90 | 90 | 180 | 270 (clockwise). Omit outFile to overwrite inFile.
pdfcpu2 rotate in.pdf 90 out.pdf
pdfcpu2 rotate -p odd in.pdf 90 # classic duplex-scan fix
pdfcpu2 rotate -p l in.pdf 270 out.pdf
cat batch.pdf | pdfcpu2 rotate -p odd - 90 - > batch-fixed.pdfpackage main
import (
"context"
"github.com/huzpsb/pdfcpu2/pkg/api"
"github.com/huzpsb/pdfcpu2/pkg/pdfcpu/model"
)
func main() {
ctx := context.Background()
conf := model.NewDefaultConfiguration()
err := api.RotateFile(ctx, "in.pdf", "out.pdf", 90, []string{"odd"}, conf)
if err != nil {
panic(err)
}
}Stream variant: api.Rotate(ctx, rs, w, rotation, selectedPages, conf).
Rotation is applied to the page dictionary (
/Rotate), not by rewriting content streams — cheap and lossless.
pdfcpu2 wiki
Getting started
Fork features
Inspect
Document
Pages
Content
Extract
Resources
Security
Viewer
Trust
Developers