Repository navigation
chore: bump go-pdfkit/pdfkit v0.21.0 -> v0.28.0 - #463
Open
tannevaled wants to merge 1 commit into
Open
tannevaled wants to merge 1 commit into
tannevaled wants to merge 1 commit into
Conversation
v0.28.0 adds /Predictor 15 (PNG-style per-row filtering) on raster images before Flate compression, kept only when smaller than plain deflate — a 26-40% size win on photographs (pdfkit PR #67). Also picks up v0.22.0's parser fuzzing fixes, v0.23.0's PNG-allocation ceiling, v0.24.0's page transitions, v0.25.0's ImportPDFPage, v0.26.0's image handles/O(1) SetAlpha/Page.ContentLen, and v0.27.0's streaming Document.Write. None of these renamed or removed an exported API; go.mod/go.sum (root and bench/, same pattern as 550721e) carry the transitive bumps MVS pulls in from pdfkit's own updated go.mod (go-gfx/gfx, go-images/images, go-opentype/opentype, go-pdfkit/reader, go-widgets/painter, andybalholm/brotli). Checked the real risk a peer go-pdfkit session flagged: whether Predictor 15 would make main's existing rsc.io/pdf-reading tests (pdfcanvas_test.go, userselect_test.go) panic ("unknown predictor 15" is rsc.io/pdf's own behavior, confirmed with a throwaway diagnostic test). Empirically: Predictor 15 IS chosen for pdfcanvas_test.go's <img> fixture (confirmed via its /DecodeParms), but neither existing test ever calls .Reader() on an image XObject's stream — they only inspect the page Content stream and font ToUnicode tables — so no existing test reads a Predictor-15-compressed stream and none panics. gotest ./pdfcanvas/... and go test -race ./pdfcanvas/... are both green. Full gate: gotest ./..., go vet ./..., govulncheck ./... clean. gofmt -l . lists 5 pre-existing unformatted files (css/clamp_test.go, css/modern_test.go, js/opfs_test.go, js/testdata/gen_add_wasm.go, js/worker_test.go), unchanged from origin/main and untouched by this bump. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bump
github.com/go-pdfkit/pdfkitv0.21.0 -> v0.28.0 (rootgo.modandbench/go.mod, same pattern as the earlierdlclark/regexp2bump in550721e, Refs #454).
go mod tidyalso pulls in the transitive version bumpspdfkit's own updated
go.modrequires (MVS):go-gfx/gfx,go-images/images,go-opentype/opentype,go-pdfkit/reader,go-widgets/painter,andybalholm/brotli. None of v0.22.0-v0.28.0 renamedor removed an exported API per the release notes, and
go build ./...confirms it empirically.
Per-version highlights relevant to this repo: v0.22.0 go1.27.3 + fuzzed
parser fixes; v0.23.0 a PNG-allocation ceiling; v0.24.0 page transitions
(additive); v0.25.0
ImportPDFPage(additive); v0.26.0 image handles,O(1)
SetAlpha,Page.ContentLen; v0.27.0Document.Writenow streamsinstead of buffering (same external signature, confirmed by compiling and
testing the existing call sites); v0.28.0, the one this bump is for,
adds
/Predictor 15(PNG-style per-row filtering) on raster imagesbefore Flate compression, kept only when it beats plain deflate —
measured 26-40% smaller on photographs (upstream go-pdfkit/pdfkit#67,
Refs go-pdfkit/pdfkit#67, already merged there);
Options.NoImagePredictorreverts to the old bytes.The risk this bump was flagged against
A peer go-pdfkit session warned that
rsc.io/pdf(used bypdfcanvas/pdfcanvas_test.goandpdfcanvas/userselect_test.goonmainto read a rendered PDF back for verification) panics on
/Predictor 15.Confirmed empirically with a throwaway diagnostic test (not committed):
pdfcanvas_test.go's<img>fixture(confirmed via its actual
/DecodeParms:<</BitsPerComponent 8 /Colors 3 /Columns 40 /Predictor 15>>)..Reader()on that image XObject directly does panic inrsc.io/pdf("unknown predictor 15")..Reader()on an image XObject'sstream —
pdfcanvas_test.goonly inspects the page'sContentsstream,font structures and
ToUnicodetables;userselect_test.gohas noraster image at all. So the panic path is never exercised by anything
on
maintoday.gotest ./pdfcanvas/...andgo test -race ./pdfcanvas/...are both green.No code change was needed to handle this — the risk is real for a test
that reads image bytes back through
rsc.io/pdf, but nothing currentlydoes.
#457 (Refs #457, stays open, not finished by this PR)
Read #457's diff (
pdfcanvas/jpegphoto_test.go, not merged, a differentbranch from this session). Its
soleImageFilterAndLenhelper also usesrsc.io/pdfto read a rendered PDF back, but it only inspects the imageXObject's
/Filtername and/Length— it never calls.Reader()todecode the stream. So it would not hit the Predictor-15 panic either, and
no comment was left on #457: the conditional risk this task asked me to
flag there did not materialize once checked against the actual diff.
Separately, #457 re-encodes opaque images >=200x200px as JPEG
(
/DCTDecode), which bypasses FlateDecode/Predictor entirely for thatcase anyway.
Testing
go build ./...,gotest ./...(root module): clean.go test -race ./pdfcanvas/...: clean.gofmt -l .: 5 pre-existing unformatted files (css/clamp_test.go,css/modern_test.go, js/opfs_test.go, js/testdata/gen_add_wasm.go,
js/worker_test.go), unchanged from
origin/main, untouched by thischange.
go vet ./...,govulncheck ./...: clean.🤖 Generated with Claude Code