Repository navigation
Grid
huzpsb edited this page Oct 25, 2026
·
1 revision
Arrange PDF pages or images onto poster-like grid sheets — every output page is a grid of m rows × n columns. Unlike N-Up the sheet size is derived from the grid, which makes grid ideal for browsing overviews.
pdfcpu2 grid [description] outFile m n inFile | imageFiles...
<description> — defaults "d:595 842, form:A4, o:rd, bo:on, ma:3, enforce:on"; same entries as N-Up (dim:/form:, o: orientation, enforce:, border:, margin:).
pdfcpu2 grid out.pdf 1 10 in.pdf # 1 row x 10 cols film-strip
pdfcpu2 grid 'p:LegalL' out.pdf 2 2 in.pdf # 2x2 on Legal landscape
pdfcpu2 grid 'o:rd' out.pdf 3 2 in.pdf # 3 rows x 2 cols, right-down
pdfcpu2 grid 'd:400 400' out.pdf 8 6 *.jpg # images into 400x400 cellspackage main
import (
"context"
"github.com/huzpsb/pdfcpu2/pkg/api"
"github.com/huzpsb/pdfcpu2/pkg/pdfcpu/model"
)
func main() {
ctx := context.Background()
conf := model.NewDefaultConfiguration()
// rows, cols, description
nup, err := api.PDFGridConfig(2, 2, "form:A4", conf)
if err != nil {
panic(err)
}
err = api.GridFile(ctx, []string{"in.pdf"}, "out.pdf", nil, nup, conf)
if err != nil {
panic(err)
}
// Image input
gridImg, _ := api.ImageGridConfig(8, 6, "d:400 400", conf)
_ = api.GridFile(ctx, []string{"a.jpg", "b.jpg"}, "out.pdf", nil, gridImg, conf)
}pdfcpu2 wiki
Getting started
Fork features
Inspect
Document
Pages
Content
Extract
Resources
Security
Viewer
Trust
Developers