From 1cb651e5cb167a3ea2a6160cce4299ea16f1c29e Mon Sep 17 00:00:00 2001 From: Mahathir Mohammad Shuvo Date: Fri, 28 Aug 2026 23:24:27 +0600 Subject: [PATCH] Document the parameter list each destination type takes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The page showed three worked examples of addNamedDestination() but never said what the parameter lists are, so the arity of each destination type had to be inferred from them — and six of the eight types appear nowhere on the page, so for those there was nothing to infer from. Sets out the eight types from ISO 32000-1 Table 151 with their positional parameters, which of them accept a null parameter, and what the zero-argument call produces. It also names the one conversion this method performs: an XYZ top is flipped against the page height, so it is given measured from the top of the page, while FitH, FitBH and FitR's vertical coordinates are written through unchanged and are measured from the bottom. The page's own two examples already differ on this and nothing said so. --- docs/destinations.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/destinations.md b/docs/destinations.md index 30becbe6f..41b06ccc1 100644 --- a/docs/destinations.md +++ b/docs/destinations.md @@ -16,6 +16,29 @@ Examples of creating anchor: // Insert anchor for this text doc.text('End of paragraph', { destination: 'ENDP' }); +Each destination type takes a fixed, positional parameter list: + +| type | parameters | +| --- | --- | +| `XYZ` | `left`, `top`, `zoom` | +| `Fit` | none | +| `FitH` | `top` | +| `FitV` | `left` | +| `FitR` | `left`, `bottom`, `right`, `top` | +| `FitB` | none | +| `FitBH` | `top` | +| `FitBV` | `left` | + +`XYZ` is the only type whose vertical coordinate is converted: give its `top` measured +from the top of the page, as everywhere else in PDFKit. The others are written through +unchanged, so `FitH` and `FitBH`'s `top`, and `FitR`'s `bottom` and `top`, are measured +from the bottom of the page. + +A destination carrying more parameters than its type takes is not valid; `FitR` must +carry all four, and `XYZ` at least `left` and `top`. For `XYZ`, `FitH`, `FitV`, `FitBH` +and `FitBV` a parameter may be `null`, which tells the reader to keep that aspect of its +current view. Called with no type at all, `addNamedDestination(name)` writes `XYZ` with +all three parameters `null`. Examples of go to link to anchor: