Summary: | Wrong computation of fz_bound_page | ||
---|---|---|---|
Product: | MuPDF | Reporter: | Jorj <jorj.x.mckie> |
Component: | mupdf | Assignee: | MuPDF bugs <mupdf-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | major | CC: | sebastian.rasmussen |
Priority: | P2 | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | All | ||
Customer: | Word Size: | --- |
Description
Jorj
2025-04-23 10:08:25 UTC
The coordinates are funky because of the interaction between the bad values in the file, and backwards compatibility logic in MuPDF's Fitz coordinate space computations. When calculating the page bounds we intersect the requested box (in this case CropBox) with the MediaBox, so that the coordinates stay within the MediaBox. The origin of the page coordinate space is based on the original CropBox coordinates. The box returned for this file is the intersection in PDF space of the CropBox [ -21 -21 616 862 ] and the MediaBox [ 0 0 595 841 ]. The top left of the intersected box is [ 0 842 ] in PDF space. This is then transformed to put the CropBox original top left coordinate [ -21 862 ] at [ 0 0 ] in the Fitz space (so +21 +21 in both x and y). Code crashing when they encounter unexpected coordinates is not our problem, but we could discuss changing the definition of the Fitz coordinate space to use as origin point the intersection of the CropBox and MediaBox rather than the raw CropBox. Fixed in commit 80645b4b00f7d5df25f8cb40385d37c5b95b2b46 Author: Tor Andersson <tor.andersson@artifex.com> Date: Wed Apr 23 16:14:04 2025 +0200 Bug 708497: Compute Fitz space origin from adjusted CropBox. Use the intersection of the CropBox and MediaBox instead of the raw CropBox when deciding the origin of the Fitz coordinate space. This way FZ_PAGE_BOX is always [0, 0, w, h] even for files where the CropBox is out of bounds. |