ArtifexSoftware / mupdf.js

JavaScript bindings for MuPDF
https://mupdfjs.readthedocs.io
GNU Affero General Public License v3.0
371 stars 22 forks source link

Link for outline requires both x and y coordinates in XYZ mode #89

Closed King-of-Infinite-Space closed 1 month ago

King-of-Infinite-Space commented 3 months ago

Hi devs, I want to add outlines to PDF that jump to specific y position of a page without affecting the x position.

Currently the outline won't work if only one of x, y is defined. It works if both x and y and defined.

let outlineItem = {
  title: 'demo',
  uri: doc.formatLinkURI({ page: 0, type: 'XYZ', y: 200, }),
  open: false,
}

console.log(outlineItem)
// { title: 'demo', uri: '#page=1&zoom=nan,nan,200', open: false }
// this looks ok

doc.outlineIterator().insert(outlineItem)
console.log(doc.outlineIterator().item())
// { title: 'demo', uri: '#page=1', open: false }
// x,y coordinates are lost unless both are set

According to PDF spec (12.3.2.2 Explicit destinations), for /XYZ mode

A null value for any of the parameters left, top, or zoom specifies that the current value of that parameter shall be retained unchanged.

Is this not implemented correctly or is there a workaround? Thanks.

jamie-lemon commented 3 months ago

@sebras I hope you can take a look at this one!

sebras commented 3 months ago

I have reported this as an upstream bug. That one will be closed once it is fixed in the mupdf project, and this bug when the update reaches mupdf.js, I assume.

sebras commented 3 months ago

The upstream bug has been fixed on upstream master. It is planned to be included in the upcoming 1.24.4 release within a few weeks.