@build-qube/papyra 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +46 -1
  2. package/dist/attachments.d.ts +76 -0
  3. package/dist/attachments.d.ts.map +1 -0
  4. package/dist/attachments.js +65 -0
  5. package/dist/attachments.js.map +1 -0
  6. package/dist/canvas.d.ts +27 -2
  7. package/dist/canvas.d.ts.map +1 -1
  8. package/dist/canvas.js +58 -5
  9. package/dist/canvas.js.map +1 -1
  10. package/dist/document.d.ts +179 -4
  11. package/dist/document.d.ts.map +1 -1
  12. package/dist/document.js +311 -12
  13. package/dist/document.js.map +1 -1
  14. package/dist/encode.d.ts +2 -2
  15. package/dist/encode.d.ts.map +1 -1
  16. package/dist/encode.js +1 -1
  17. package/dist/encode.js.map +1 -1
  18. package/dist/encoded.d.ts +34 -5
  19. package/dist/encoded.d.ts.map +1 -1
  20. package/dist/encoded.js +28 -0
  21. package/dist/encoded.js.map +1 -1
  22. package/dist/errors.d.ts +45 -0
  23. package/dist/errors.d.ts.map +1 -0
  24. package/dist/errors.js +69 -0
  25. package/dist/errors.js.map +1 -0
  26. package/dist/fingerprint.d.ts +18 -0
  27. package/dist/fingerprint.d.ts.map +1 -0
  28. package/dist/fingerprint.js +48 -0
  29. package/dist/fingerprint.js.map +1 -0
  30. package/dist/index.d.ts +14 -5
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +6 -2
  33. package/dist/index.js.map +1 -1
  34. package/dist/links.d.ts +53 -0
  35. package/dist/links.d.ts.map +1 -0
  36. package/dist/links.js +26 -0
  37. package/dist/links.js.map +1 -0
  38. package/dist/outline.d.ts +9 -1
  39. package/dist/outline.d.ts.map +1 -1
  40. package/dist/outline.js +9 -3
  41. package/dist/outline.js.map +1 -1
  42. package/dist/structure.d.ts +119 -0
  43. package/dist/structure.d.ts.map +1 -0
  44. package/dist/structure.js +115 -0
  45. package/dist/structure.js.map +1 -0
  46. package/dist/text.d.ts +20 -0
  47. package/dist/text.d.ts.map +1 -1
  48. package/dist/text.js +9 -0
  49. package/dist/text.js.map +1 -1
  50. package/dist/types.d.ts +75 -0
  51. package/dist/types.d.ts.map +1 -1
  52. package/dist/viewport.d.ts +129 -0
  53. package/dist/viewport.d.ts.map +1 -0
  54. package/dist/viewport.js +163 -0
  55. package/dist/viewport.js.map +1 -0
  56. package/package.json +2 -2
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Rebuild the tree from the flat pre-order list the bindings return.
3
+ *
4
+ * The same stack-by-level pass {@link buildOutlineTree} uses, and correct for the same
5
+ * reason: pre-order guarantees a node's parent is the most recent node one level
6
+ * shallower. A level that skips a step cannot come from our own walker, and is clamped
7
+ * rather than trusted — a malformed document should flatten, not crash.
8
+ */
9
+ export function buildStructTree(entries) {
10
+ const roots = [];
11
+ const stack = [];
12
+ for (const entry of entries) {
13
+ const node = {
14
+ role: entry.role,
15
+ rawRole: entry.rawRole,
16
+ content: entry.content,
17
+ alt: entry.alt ?? null,
18
+ actualText: entry.actualText ?? null,
19
+ lang: entry.lang ?? null,
20
+ title: entry.title ?? null,
21
+ children: [],
22
+ };
23
+ const level = Math.min(entry.level, stack.length);
24
+ stack.length = level;
25
+ const parent = stack[level - 1];
26
+ if (parent)
27
+ parent.children.push(node);
28
+ else
29
+ roots.push(node);
30
+ stack.push(node);
31
+ }
32
+ return roots;
33
+ }
34
+ /** Walk a structure tree depth-first, yielding each node with its depth. */
35
+ export function* walkStructTree(nodes, depth = 0) {
36
+ for (const node of nodes) {
37
+ yield { node, depth };
38
+ yield* walkStructTree(node.children, depth + 1);
39
+ }
40
+ }
41
+ /**
42
+ * Put a page's lines into the reading order the document declares.
43
+ *
44
+ * This is the payoff of a tagged PDF and the one thing geometry cannot recover: on a
45
+ * two-column page the content stream may draw both columns interleaved, and no line
46
+ * grouping fixes that, because the drawing order genuinely is what it is. The
47
+ * structure tree states the intended order outright.
48
+ *
49
+ * Lines are keyed by their first glyph's {@link TextLine.mcid}, so a line is placed by
50
+ * the element that *starts* it. Ties — several lines inside one `P`, which is the
51
+ * normal case for a wrapped paragraph — keep their original relative order, so within
52
+ * an element the result is still the content stream's sequence. That is what makes
53
+ * this safe on a document whose tagging is partial.
54
+ *
55
+ * Lines with no structure element go **last**, rather than being dropped: untagged
56
+ * content is usually a running head or a page number, and losing it silently would be
57
+ * worse than putting it at the end. Pass `includeUntagged: false` to drop them.
58
+ *
59
+ * Returns the lines in content-stream order, unchanged, when the page has no tagged
60
+ * content at all — an untagged document is the common case and should not come back
61
+ * empty or reshuffled.
62
+ */
63
+ export function readingOrder(text, tree, options = {}) {
64
+ const { includeUntagged = true } = options;
65
+ // Pre-order position of the element owning each mcid on this page. Built once per
66
+ // call: a tagged document tags every paragraph, so this is the whole tree, and
67
+ // doing it per line would be quadratic on exactly the documents that use it.
68
+ const owner = new Map();
69
+ let order = 0;
70
+ for (const { node } of walkStructTree(tree)) {
71
+ const position = order++;
72
+ for (const content of node.content) {
73
+ if (content.page !== text.page)
74
+ continue;
75
+ // First writer wins: an mcid claimed twice is malformed, and the earlier
76
+ // element is the one pre-order would have reached first anyway.
77
+ if (!owner.has(content.mcid)) {
78
+ owner.set(content.mcid, { node, order: position });
79
+ }
80
+ }
81
+ }
82
+ const ordered = text.lines.map((line, index) => {
83
+ const found = line.mcid === undefined ? undefined : owner.get(line.mcid);
84
+ return {
85
+ line,
86
+ node: found?.node ?? null,
87
+ // Untagged lines sort after every tagged one.
88
+ order: found?.order ?? Number.POSITIVE_INFINITY,
89
+ index,
90
+ };
91
+ });
92
+ if (owner.size === 0) {
93
+ return includeUntagged
94
+ ? ordered.map(({ line, node }) => ({ line, node }))
95
+ : [];
96
+ }
97
+ // `index` breaks ties, which keeps the sort stable across engines rather than
98
+ // relying on the specification's guarantee holding for every runtime we ship on.
99
+ ordered.sort((a, b) => a.order - b.order || a.index - b.index);
100
+ return ordered
101
+ .filter((entry) => includeUntagged || entry.node !== null)
102
+ .map(({ line, node }) => ({ line, node }));
103
+ }
104
+ /**
105
+ * Every character of a page in declared reading order, one line per entry.
106
+ *
107
+ * The structure-aware counterpart to {@link pageString}; identical to it on an
108
+ * untagged page.
109
+ */
110
+ export function structuredPageString(text, tree) {
111
+ return readingOrder(text, tree)
112
+ .map(({ line }) => line.text)
113
+ .join('\n');
114
+ }
115
+ //# sourceMappingURL=structure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structure.js","sourceRoot":"","sources":["../src/structure.ts"],"names":[],"mappings":"AAiEA;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,OAA+B;IAC7D,MAAM,KAAK,GAAiB,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAiB,EAAE,CAAC;IAE/B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAe;YACvB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,OAAO,EAAE,KAAK,CAAC,OAAyC;YACxD,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,IAAI;YACtB,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,IAAI;YACpC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,IAAI;YACxB,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,IAAI;YAC1B,QAAQ,EAAE,EAAE;SACb,CAAC;QAEF,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAClD,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;QACrB,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAChC,IAAI,MAAM;YAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;YAClC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,KAAK,CAAC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AAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;SAC5B,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
package/dist/text.d.ts CHANGED
@@ -27,6 +27,24 @@ export interface TextLine {
27
27
  readonly ascent: number;
28
28
  /** Extent below the baseline. */
29
29
  readonly descent: number;
30
+ /**
31
+ * Marked-content id of the line's **first** glyph, joining this line to the
32
+ * structure tree — see {@link StructNode.content} and {@link readingOrder}.
33
+ *
34
+ * Absent on an untagged page, and on a tagged page for content the document left
35
+ * outside any marked-content sequence, which is where running heads and page
36
+ * numbers usually live.
37
+ *
38
+ * Optional rather than `null` because lines cross the binding as-is rather than
39
+ * being rebuilt one by one — a page is thousands of them — so an absent id arrives
40
+ * as `undefined` and saying otherwise would be a lie about the runtime shape.
41
+ *
42
+ * The *first* glyph rather than all of them: lines are grouped by geometry and
43
+ * tagging does not change that grouping, so a line whose middle switches to a
44
+ * `Span` stays one line. Ordering by the element that starts a line is sound;
45
+ * reading this as "every character here belongs to that element" is not.
46
+ */
47
+ readonly mcid?: number;
30
48
  }
31
49
  /**
32
50
  * The text of one page.
@@ -106,6 +124,8 @@ export declare function pageTextBytes(text: PageText): number;
106
124
  export declare function lineQuad(line: TextLine, start: number, end: number): Quad;
107
125
  /** The smallest upright rectangle containing `quad`. */
108
126
  export declare function quadBounds(quad: Quad): Rect;
127
+ /** Scale a rect from 72-DPI page space into a render's pixels. */
128
+ export declare function scaleRect(rect: Rect, scale: number): Rect;
109
129
  /** Scale a quad from 72-DPI page space into a render's pixels. */
110
130
  export declare function scaleQuad(quad: Quad, scale: number): Quad;
111
131
  //# sourceMappingURL=text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,IAAI,cAAc,EAE3B,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;GAOG;A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AAE,MAAM,CAAC;IACnB,aAAa;IACb,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,cAAc;IACd,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,gBAAgB;AAChB,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,QAAQ,CAMzE;AAED,oDAAoD;AACpD,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAEjD;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAMpD;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAyBzE;AAED,wDAAwD;AACxD,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAM3C;AAED,kEAAkE;AAClE,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAOzD;AAED,kEAAkE;AAClE,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAWzD"}
package/dist/text.js CHANGED
@@ -56,6 +56,15 @@ export function quadBounds(quad) {
56
56
  const y = Math.min(...ys);
57
57
  return { x, y, width: Math.max(...xs) - x, height: Math.max(...ys) - y };
58
58
  }
59
+ /** Scale a rect from 72-DPI page space into a render's pixels. */
60
+ export function scaleRect(rect, scale) {
61
+ return {
62
+ x: rect.x * scale,
63
+ y: rect.y * scale,
64
+ width: rect.width * scale,
65
+ height: rect.height * scale,
66
+ };
67
+ }
59
68
  /** Scale a quad from 72-DPI page space into a render's pixels. */
60
69
  export function scaleQuad(quad, scale) {
61
70
  return {
package/dist/text.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","sourceRoot":"","sources":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,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;AAC3E,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,SAAS,CAAC,IAAU,EAAE,KAAa;IACjD,OAAO;QACL,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,KAAK;QACjB,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,KAAK;QACjB,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,KAAK;QACzB,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,KAAK;KAC5B,CAAC;AACJ,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,SAAS,CAAC,IAAU,EAAE,KAAa;IACjD,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK;QACnB,EAAE,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK;QACnB,EAAE,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK;QACnB,EAAE,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK;QACnB,EAAE,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK;QACnB,EAAE,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK;QACnB,EAAE,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK;QACnB,EAAE,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK;KACpB,CAAC;AACJ,CAAC;AAED,SAAS,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,IAAY;IACrD,OAAO,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AACzD,CAAC"}
package/dist/types.d.ts CHANGED
@@ -26,6 +26,23 @@ export interface RenderOptions {
26
26
  * cost proportional to what is actually displayed.
27
27
  */
28
28
  fitWidth?: number;
29
+ /**
30
+ * Draw the page's annotations — links, highlights, stamps, filled form fields.
31
+ *
32
+ * On by default, which is what a PDF viewer is expected to show. Turn it off when
33
+ * you are drawing them yourself: a viewer that paints its own link or highlight
34
+ * layer over the bitmap otherwise shows every annotation twice, once from the
35
+ * document's appearance stream and once from its own.
36
+ *
37
+ * A boolean rather than pdf.js's four-way `annotationMode`, because that is the
38
+ * whole of what the engine offers. The two modes this has no answer for —
39
+ * `enableForms` and `enableStorage` — are about writing field values back, which
40
+ * papyra does not do.
41
+ *
42
+ * Part of the cache key, so flipping it re-renders instead of returning the
43
+ * previous answer.
44
+ */
45
+ annotations?: boolean;
29
46
  }
30
47
  /** {@link RenderOptions}, plus the two dials that only apply to a stream. */
31
48
  export interface StreamOptions extends RenderOptions {
@@ -42,6 +59,32 @@ export interface StreamOptions extends RenderOptions {
42
59
  */
43
60
  order?: readonly number[];
44
61
  }
62
+ /**
63
+ * Options for {@link Document.renderSvg}. No `dpi` and no `fitWidth`: an SVG carries
64
+ * the page's own point dimensions and rasterises at whatever size it is drawn.
65
+ */
66
+ export interface SvgOptions {
67
+ /** Scheduling order, exactly as in {@link RenderOptions.priority}. */
68
+ priority?: number;
69
+ /** Abort a request that has not started yet. */
70
+ signal?: AbortSignal;
71
+ /**
72
+ * Defaults to `'white'`, matching how pages rasterise.
73
+ *
74
+ * Choose `'transparent'` when the SVG is going to be placed onto something else —
75
+ * an opaque rectangle behind vector artwork is the one thing a consumer cannot
76
+ * undo.
77
+ */
78
+ background?: 'white' | 'transparent';
79
+ /**
80
+ * Draw annotations, exactly as in {@link RenderOptions.annotations}. Defaults to on.
81
+ *
82
+ * Worth turning off more often here than for a raster page: an SVG is usually headed
83
+ * somewhere that will lay its own interaction over the artwork, and a baked-in link
84
+ * border is not removable afterwards.
85
+ */
86
+ annotations?: boolean;
87
+ }
45
88
  /** A rendered page. `data` is tightly packed RGBA8, `height * stride` bytes. */
46
89
  export interface RenderedPage {
47
90
  /** Output width in pixels, after `dpi` or `fitWidth` was applied. */
@@ -78,6 +121,38 @@ export interface PageSize {
78
121
  /** Height in points, with rotation and the crop box already applied. */
79
122
  readonly height: number;
80
123
  }
124
+ /**
125
+ * The document information dictionary — what the file says about itself.
126
+ *
127
+ * Every field is independently optional, and a field the document left blank reads as
128
+ * `null` rather than an empty string. None of it is verified: a producer writes what
129
+ * it likes, and `title` in particular is frequently a filename or absent entirely, so
130
+ * a viewer showing a document name should fall back to its own.
131
+ */
132
+ export interface DocumentMetadata {
133
+ /** The document's own title, which is frequently a filename or absent. */
134
+ readonly title: string | null;
135
+ /** Who the document claims to be by. */
136
+ readonly author: string | null;
137
+ /** A one-line description. Rare outside of published documents. */
138
+ readonly subject: string | null;
139
+ /** Free text, and not reliably a delimited list — producers use commas or spaces. */
140
+ readonly keywords: string | null;
141
+ /** The application the document was authored in, e.g. `AutoCAD`. */
142
+ readonly creator: string | null;
143
+ /** The application that wrote the PDF, e.g. `Ghostscript`. */
144
+ readonly producer: string | null;
145
+ /**
146
+ * When the document was created, as an ISO 8601 string — `new Date(created)` parses
147
+ * it directly.
148
+ *
149
+ * A PDF date may be as short as a year, in which case the missing components read
150
+ * as January 1st. It is also self-reported, and clocks lie.
151
+ */
152
+ readonly created: string | null;
153
+ /** When the document was last modified, ISO 8601. */
154
+ readonly modified: string | null;
155
+ }
81
156
  /** Everything fixed for the lifetime of a {@link Document}: its queue and its caches. */
82
157
  export interface OpenOptions {
83
158
  /** Password for an encrypted document. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,iFAAiF;AACjF,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,WAAW,GAAG,eAAe,GAAG,IAAI,CAAC;AAE1E,4DAA4D;AAC5D,MAAM,WAAW,aAAa;IAC5B;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,MAAM,CAAC,EAAE,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M,GAAG,IAAI,CAAC;IAChC,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,yFAAyF;AACzF,MAAM,WAAW,WAAW;IAC1B,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,2CAA2C;AAC3C,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD;;;;;OAKG;IACH,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oFAAoF;IACpF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB"}
@@ -0,0 +1,129 @@
1
+ import type { Quad, Rect } from './text.js';
2
+ import type { PageSize, RenderedPage } from './types.js';
3
+ /**
4
+ * Quarter turns clockwise, applied on top of whatever the page's own `/Rotate` already
5
+ * did.
6
+ *
7
+ * A viewer's rotate button, not a property of the document: papyra has already applied
8
+ * `/Rotate` by the time you see a {@link PageSize} or a {@link PageText}, so this turns
9
+ * the page relative to how it is meant to be read.
10
+ */
11
+ export type Rotation = 0 | 90 | 180 | 270;
12
+ /** How to build a {@link Viewport}. Size it by `dpi` or by `fitWidth`, not both. */
13
+ export interface ViewportOptions {
14
+ /** Dots per inch. 72 is the page's natural size. Defaults to 72. */
15
+ dpi?: number;
16
+ /**
17
+ * Target output width in pixels, measured **after** rotation. Overrides `dpi`.
18
+ *
19
+ * This is the reason to size through a viewport rather than through
20
+ * {@link RenderOptions.fitWidth} directly: at 90° the width on screen is the page's
21
+ * height, so the two mean different things the moment the page is turned. Fitting a
22
+ * column of viewport width is what a viewer actually wants, and
23
+ * {@link Viewport.dpi} carries the answer back to the render call.
24
+ */
25
+ fitWidth?: number;
26
+ /** Quarter turns clockwise. Defaults to none. */
27
+ rotation?: Rotation;
28
+ }
29
+ /**
30
+ * A page's mapping from PDF points to the pixels on screen: a scale, a rotation, and
31
+ * the output size the two produce.
32
+ *
33
+ * papyra renders pages unrotated — the engine has no transform knob, and turning a
34
+ * bitmap is a copy nobody needs when a canvas can do it in the paint call — so a
35
+ * rotated view is a viewer-side construction. This is that construction, and it is the
36
+ * one place the rotation is written down: {@link viewportRect} and
37
+ * {@link viewportQuad} put link regions and text highlights in the same space as the
38
+ * pixels {@link paintToCanvas} draws, and disagreeing about the angle is the whole
39
+ * failure mode.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const vp = viewport(doc.pageSize(0), { fitWidth: 1600, rotation: 90 });
44
+ * const page = await doc.renderPage(0, { dpi: vp.dpi });
45
+ * paintToCanvas(page, canvas, { rotation: vp.rotation });
46
+ * for (const link of await doc.links(0)) {
47
+ * place(hitbox, viewportRect(link.rect, vp));
48
+ * }
49
+ * ```
50
+ */
51
+ export interface Viewport {
52
+ /**
53
+ * Output width in pixels, after rotation.
54
+ *
55
+ * A whole number, and the same one the renderer arrives at: it floors a page's
56
+ * scaled point size to get its pixmap, so a viewport that reported the fractional
57
+ * value would be a pixel wider than the bitmap it describes about half the time.
58
+ */
59
+ readonly width: number;
60
+ /** Output height in pixels, after rotation. Floored, as {@link width} is. */
61
+ readonly height: number;
62
+ /** Pixels per PDF point. `1` is 72 DPI. */
63
+ readonly scale: number;
64
+ /**
65
+ * The DPI to render at. Pass straight to {@link RenderOptions.dpi}.
66
+ *
67
+ * Always describes the *unrotated* render, which is the only kind there is — the
68
+ * rotation is applied when the bitmap is painted, not when it is produced.
69
+ */
70
+ readonly dpi: number;
71
+ /** The rotation this viewport applies. */
72
+ readonly rotation: Rotation;
73
+ /** The page size it was built from, in points, before rotation. */
74
+ readonly page: PageSize;
75
+ }
76
+ /**
77
+ * A page's dimensions after a rotation, still in points.
78
+ *
79
+ * The layout half of a rotated view, and separate from {@link viewport} because it is
80
+ * needed *before* a scale exists: a viewer sizing its page boxes, or resolving a
81
+ * fit-to-width against the turned page, is working in points and cannot use a
82
+ * viewport's floored pixel dimensions without losing the fraction of a point that
83
+ * decides a box's final rounding.
84
+ *
85
+ * Returns the same object when there is nothing to swap, so it is safe in a
86
+ * dependency array.
87
+ */
88
+ export declare function rotateSize(size: PageSize, rotation: Rotation): PageSize;
89
+ /**
90
+ * Build a {@link Viewport} for a page.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * const vp = viewport(doc.pageSize(0), { fitWidth: 1600, rotation: 90 });
95
+ * canvasEl.style.width = `${vp.width}px`;
96
+ * canvasEl.style.height = `${vp.height}px`;
97
+ * ```
98
+ */
99
+ export declare function viewport(size: PageSize, options?: ViewportOptions): Viewport;
100
+ /**
101
+ * Put a rect — a {@link PageLink.rect}, a {@link quadBounds} result — into a viewport's
102
+ * pixels.
103
+ *
104
+ * Stays axis-aligned, because the rotations are quarter turns: only the corners swap
105
+ * roles. Supersedes {@link scaleRect} for anything drawn over a rotated view;
106
+ * `scaleRect` remains the cheaper call when the rotation is always zero.
107
+ */
108
+ export declare function viewportRect(rect: Rect, vp: Viewport): Rect;
109
+ /**
110
+ * Put a {@link lineQuad} into a viewport's pixels.
111
+ *
112
+ * The corner order survives: rotating the page rotates the text with it, so the
113
+ * quad's top-left is still the top-left of the text's own orientation. That is what
114
+ * keeps a highlight on a drawing's vertical dimension label correct at every angle
115
+ * rather than only at zero.
116
+ */
117
+ export declare function viewportQuad(quad: Quad, vp: Viewport): Quad;
118
+ /**
119
+ * Turn a rendered page's pixels, returning a new {@link RenderedPage}.
120
+ *
121
+ * **Prefer {@link paintToCanvas} with a `rotation` in a browser** — a canvas rotates
122
+ * in the draw call and this copies the whole buffer, which is 7 MB and a few tens of
123
+ * milliseconds for a 1600px ARCH-E sheet. This exists for the paths that have no
124
+ * canvas: writing a rotated PNG from Node, handing bytes to an encoder.
125
+ *
126
+ * A rotation of `0` returns the page unchanged rather than copying it.
127
+ */
128
+ export declare function rotatePage(page: RenderedPage, rotation: Rotation): RenderedPage;
129
+ //# sourceMappingURL=viewport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../src/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC;AAE1C,oFAAoF;AACpF,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;CACzB;AAOD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAEvE;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,QAAQ,EACd,OAAO,GAAE,eAAoB,GAC5B,QAAQ,CAmBV;AA0BD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI,CAW3D;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI,CAe3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,QAAQ,GACjB,YAAY,CA6Cd"}
@@ -0,0 +1,163 @@
1
+ /** True when the rotation exchanges the page's width and height. */
2
+ function turned(rotation) {
3
+ return rotation === 90 || rotation === 270;
4
+ }
5
+ /**
6
+ * A page's dimensions after a rotation, still in points.
7
+ *
8
+ * The layout half of a rotated view, and separate from {@link viewport} because it is
9
+ * needed *before* a scale exists: a viewer sizing its page boxes, or resolving a
10
+ * fit-to-width against the turned page, is working in points and cannot use a
11
+ * viewport's floored pixel dimensions without losing the fraction of a point that
12
+ * decides a box's final rounding.
13
+ *
14
+ * Returns the same object when there is nothing to swap, so it is safe in a
15
+ * dependency array.
16
+ */
17
+ export function rotateSize(size, rotation) {
18
+ return turned(rotation) ? { width: size.height, height: size.width } : size;
19
+ }
20
+ /**
21
+ * Build a {@link Viewport} for a page.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const vp = viewport(doc.pageSize(0), { fitWidth: 1600, rotation: 90 });
26
+ * canvasEl.style.width = `${vp.width}px`;
27
+ * canvasEl.style.height = `${vp.height}px`;
28
+ * ```
29
+ */
30
+ export function viewport(size, options = {}) {
31
+ const rotation = options.rotation ?? 0;
32
+ // `fitWidth` is measured on screen, so at 90° it constrains the page's height.
33
+ const along = turned(rotation) ? size.height : size.width;
34
+ const scale = options.fitWidth !== undefined && along > 0
35
+ ? options.fitWidth / along
36
+ : (options.dpi ?? 72) / 72;
37
+ const shown = rotateSize(size, rotation);
38
+ return {
39
+ width: Math.floor(shown.width * scale),
40
+ height: Math.floor(shown.height * scale),
41
+ scale,
42
+ dpi: scale * 72,
43
+ rotation,
44
+ page: size,
45
+ };
46
+ }
47
+ /**
48
+ * Map a point from 72-DPI page space into a viewport's pixels.
49
+ *
50
+ * Rotation happens in point space and the scale is applied after, so a rect and a quad
51
+ * on the same page cannot drift apart by a rounding step.
52
+ */
53
+ function project(x, y, vp) {
54
+ const { width: w, height: h } = vp.page;
55
+ switch (vp.rotation) {
56
+ case 90:
57
+ return { x: (h - y) * vp.scale, y: x * vp.scale };
58
+ case 180:
59
+ return { x: (w - x) * vp.scale, y: (h - y) * vp.scale };
60
+ case 270:
61
+ return { x: y * vp.scale, y: (w - x) * vp.scale };
62
+ default:
63
+ return { x: x * vp.scale, y: y * vp.scale };
64
+ }
65
+ }
66
+ /**
67
+ * Put a rect — a {@link PageLink.rect}, a {@link quadBounds} result — into a viewport's
68
+ * pixels.
69
+ *
70
+ * Stays axis-aligned, because the rotations are quarter turns: only the corners swap
71
+ * roles. Supersedes {@link scaleRect} for anything drawn over a rotated view;
72
+ * `scaleRect` remains the cheaper call when the rotation is always zero.
73
+ */
74
+ export function viewportRect(rect, vp) {
75
+ const a = project(rect.x, rect.y, vp);
76
+ const b = project(rect.x + rect.width, rect.y + rect.height, vp);
77
+ const x = Math.min(a.x, b.x);
78
+ const y = Math.min(a.y, b.y);
79
+ return {
80
+ x,
81
+ y,
82
+ width: Math.max(a.x, b.x) - x,
83
+ height: Math.max(a.y, b.y) - y,
84
+ };
85
+ }
86
+ /**
87
+ * Put a {@link lineQuad} into a viewport's pixels.
88
+ *
89
+ * The corner order survives: rotating the page rotates the text with it, so the
90
+ * quad's top-left is still the top-left of the text's own orientation. That is what
91
+ * keeps a highlight on a drawing's vertical dimension label correct at every angle
92
+ * rather than only at zero.
93
+ */
94
+ export function viewportQuad(quad, vp) {
95
+ const p0 = project(quad.x0, quad.y0, vp);
96
+ const p1 = project(quad.x1, quad.y1, vp);
97
+ const p2 = project(quad.x2, quad.y2, vp);
98
+ const p3 = project(quad.x3, quad.y3, vp);
99
+ return {
100
+ x0: p0.x,
101
+ y0: p0.y,
102
+ x1: p1.x,
103
+ y1: p1.y,
104
+ x2: p2.x,
105
+ y2: p2.y,
106
+ x3: p3.x,
107
+ y3: p3.y,
108
+ };
109
+ }
110
+ /**
111
+ * Turn a rendered page's pixels, returning a new {@link RenderedPage}.
112
+ *
113
+ * **Prefer {@link paintToCanvas} with a `rotation` in a browser** — a canvas rotates
114
+ * in the draw call and this copies the whole buffer, which is 7 MB and a few tens of
115
+ * milliseconds for a 1600px ARCH-E sheet. This exists for the paths that have no
116
+ * canvas: writing a rotated PNG from Node, handing bytes to an encoder.
117
+ *
118
+ * A rotation of `0` returns the page unchanged rather than copying it.
119
+ */
120
+ export function rotatePage(page, rotation) {
121
+ if (rotation === 0)
122
+ return page;
123
+ const { width: w, height: h, stride } = page;
124
+ const outW = turned(rotation) ? h : w;
125
+ const outH = turned(rotation) ? w : h;
126
+ const out = new Uint8Array(outW * outH * 4);
127
+ // One 32-bit move per pixel instead of four 8-bit ones, when the views allow it. On
128
+ // wasm `page.data` is a window onto shared linear memory at an arbitrary offset, and
129
+ // `Uint32Array` refuses one that is not 4-byte aligned — hence the byte fallback
130
+ // rather than an assumption.
131
+ const aligned = page.data.byteOffset % 4 === 0 && stride % 4 === 0;
132
+ const src32 = aligned
133
+ ? new Uint32Array(page.data.buffer, page.data.byteOffset, (h * stride) / 4)
134
+ : null;
135
+ const dst32 = src32 ? new Uint32Array(out.buffer) : null;
136
+ const srcRow = stride / 4;
137
+ for (let y = 0; y < h; y++) {
138
+ for (let x = 0; x < w; x++) {
139
+ // Where this source pixel lands, per quarter turn clockwise.
140
+ const dx = rotation === 90 ? h - 1 - y : rotation === 180 ? w - 1 - x : y;
141
+ const dy = rotation === 90 ? x : rotation === 180 ? h - 1 - y : w - 1 - x;
142
+ if (src32 && dst32) {
143
+ dst32[dy * outW + dx] = src32[y * srcRow + x];
144
+ }
145
+ else {
146
+ const s = y * stride + x * 4;
147
+ const d = (dy * outW + dx) * 4;
148
+ out[d] = page.data[s];
149
+ out[d + 1] = page.data[s + 1];
150
+ out[d + 2] = page.data[s + 2];
151
+ out[d + 3] = page.data[s + 3];
152
+ }
153
+ }
154
+ }
155
+ return {
156
+ width: outW,
157
+ height: outH,
158
+ stride: outW * 4,
159
+ format: page.format,
160
+ data: out,
161
+ };
162
+ }
163
+ //# sourceMappingURL=viewport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewport.js","sourceRoot":"","sources":["../src/viewport.ts"],"names":[],"mappings":"AA+EA,oEAAoE;AACpE,SAAS,MAAM,CAAC,QAAkB;IAChC,OAAO,QAAQ,KAAK,EAAE,IAAI,QAAQ,KAAK,GAAG,CAAC;AAC7C,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,IAAc,EAAE,QAAkB;IAC3D,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9E,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CACtB,IAAc,EACd,OAAO,GAAoB,EAAE;IAE7B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;IACvC,+EAA+E;IAC/E,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;IAC1D,MAAM,KAAK,GACT,OAAO,CAAC,QAAQ,KAAK,SAAS,IAAI,KAAK,GAAG,CAAC;Q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,GAAG,CAAC,CAAC;gBAC/B,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAW,CAAC;gBAChC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAW,CAAC;gBACxC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAW,CAAC;gBACxC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAW,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,IAAI,GAAG,CAAC;QAChB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,IAAI,EAAE,GAAG;KACV,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@build-qube/papyra",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Fast PDF rendering for Node and the browser, powered by Rust",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -40,7 +40,7 @@
40
40
  "test:integration": "bun test test/integration"
41
41
  },
42
42
  "dependencies": {
43
- "@build-qube/papyra-native": "0.1.0"
43
+ "@build-qube/papyra-native": "0.3.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "typescript": "^7.0.2"