@memberjunction/ng-react 6.2.2 → 6.3.0-edge.1

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.
package/README.md CHANGED
@@ -108,6 +108,17 @@ componentProps = {
108
108
 
109
109
  Hosts that drive a component from outside (an agent operating it through a realtime channel, a toolbar) call the standard component methods on the `MJReactComponent` instance: `InvokeMethod(name, ...args)`, `HasMethod(name)`, `GetCurrentDataState()`, `Refresh()` (the component's own `refresh()` when it registered one, otherwise a re-render), `Print()`, `validate()`, `IsDirty()`, `Reset()`, `ScrollTo(target)` and `Focus(target?)`. Each is a no-op (or `undefined`/`false`) until the component has initialized (`Initialized` fires). A new `Component` input is a new version: the component reinitializes in place and `Initialized` fires again.
110
110
 
111
+ ### PDF Export
112
+
113
+ `CapturePDF(orientation = 'portrait', title?)` downloads the rendered component as an A4 PDF named `<title>_<date>.pdf` (the title defaults to the spec's title or name). The artifact viewer offers it from its header as **PDF – Portrait** / **PDF – Landscape**.
114
+
115
+ - The component is laid out at the page's printable width (718 CSS px portrait, 1047 landscape) so it prints the same whatever the viewer's size; content wider than that (a wide table) is laid out wider and scaled down to fit. The host page around the component is not changed.
116
+ - Content behind inner scrollbars is included, Chart.js charts are re-rendered at 3x, and `data-export-control="true"` elements (export buttons) are left out.
117
+ - Page breaks avoid splitting charts, rows, form fields and text blocks, keep a table's lead-in (title, search box, header row) with its first row and headings with what follows, and shrink a page by up to 20% when that keeps it from being left mostly empty.
118
+ - Content rendered in portals (antd modals, drawers) is outside the component and not included. Each page is one image, so text in the PDF is not selectable.
119
+
120
+ The pieces are exported for reuse: `ExportComponentToPDF(element, title, orientation)`, `PlanPdfPages`, `EnterPrintMode`, and `BuildImagePdf` (a minimal JPEG-per-page PDF writer).
121
+
111
122
  ## Services
112
123
 
113
124
  | Service | Purpose |
@@ -141,3 +152,4 @@ ReactDebugConfig.logLevel = 'verbose';
141
152
  - [@memberjunction/global](../../../MJGlobal/README.md) -- Global utilities
142
153
  - React and ReactDOM (loaded at runtime from CDN)
143
154
  - Babel standalone (loaded at runtime for JSX transpilation)
155
+ - [html-to-image](https://github.com/bubkoo/html-to-image) -- DOM capture for PDF export
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,265 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { BlendBackgrounds, EnterPrintMode, HorizontalOverflow, IsBlankPixels, PageLayoutWidth, PdfFileName, PinLayoutWidth, PlanPdfPages, SharpenCharts, TableLeadBlock } from '../lib/export/component-pdf-export';
3
+ /** jsdom has no layout: give an element the scroll and client heights a browser would report. */
4
+ function setHeights(element, scrollHeight, clientHeight) {
5
+ Object.defineProperty(element, 'scrollHeight', { configurable: true, get: () => scrollHeight });
6
+ Object.defineProperty(element, 'clientHeight', { configurable: true, get: () => clientHeight });
7
+ }
8
+ describe('PlanPdfPages', () => {
9
+ it('fits a tall capture to the A4 portrait width and cuts it into page-height bands', () => {
10
+ const plan = PlanPdfPages(1900, 5000);
11
+ expect(plan).toMatchObject({ Orientation: 'portrait', PageWidthMM: 210, PageHeightMM: 297, DrawWidthMM: 190 });
12
+ // 277mm of usable height at 190mm / 1900px = 0.1 mm per pixel
13
+ expect(plan.Slices.map(s => [s.SourceY, s.SourceHeight])).toEqual([[0, 2770], [2770, 2230]]);
14
+ expect(plan.Slices[1].DrawHeightMM).toBeCloseTo(223);
15
+ });
16
+ it('uses the requested orientation, and one page when the capture fits', () => {
17
+ const plan = PlanPdfPages(3000, 1000, 'landscape');
18
+ expect(plan.Orientation).toBe('landscape');
19
+ expect(plan.Slices).toHaveLength(1);
20
+ expect(plan.Slices[0]).toMatchObject({ SourceY: 0, SourceHeight: 1000 });
21
+ });
22
+ });
23
+ describe('PlanPdfPages page breaks', () => {
24
+ // 1900px wide: a page holds 2770px (0.1 mm per pixel on 190mm)
25
+ const heights = (blocks) => PlanPdfPages(1900, 5000, 'portrait', blocks).Slices.map(s => s.SourceHeight);
26
+ it('moves a cut to the top of a row or chart it would split, however far back, when it fits a page', () => {
27
+ expect(heights([{ Top: 2700, Bottom: 2800, Atomic: true }])).toEqual([2700, 2300]);
28
+ // a 2200px chart starting at 1300 that even a shrunk page cannot hold: the page ends at its top
29
+ expect(heights([{ Top: 1300, Bottom: 3500, Atomic: true }])[0]).toBe(1300);
30
+ });
31
+ it('splits a large card between its children, but moves it whole when only its header would stay behind', () => {
32
+ const card = { Top: 1000, Bottom: 3500, Atomic: false };
33
+ const rows = [{ Top: 2700, Bottom: 2790, Atomic: true }];
34
+ expect(heights([card, ...rows])[0]).toBe(2700); // split between rows inside the card
35
+ const lateCard = { Top: 2400, Bottom: 3800, Atomic: false }; // only 370px (< 15% of a page) above the cut: its title
36
+ expect(heights([lateCard])[0]).toBe(2400);
37
+ });
38
+ it('keeps small containers together and splits anything taller than a page', () => {
39
+ expect(heights([{ Top: 2650, Bottom: 2900, Atomic: false }])[0]).toBe(2650); // a KPI tile: < 15% of a page
40
+ expect(heights([{ Top: 500, Bottom: 3400, Atomic: true }])[0]).toBe(2770); // taller than a page
41
+ });
42
+ it('moves a card that fits a page whole when only its last lines would carry over', () => {
43
+ // 130px (< 15% of a page) would carry over; moving the card leaves the page 83% full, so no shrink
44
+ expect(heights([{ Top: 2300, Bottom: 2900, Atomic: false }])[0]).toBe(2300);
45
+ });
46
+ it('keeps a table header row or heading on the page of what follows it', () => {
47
+ const thead = { Top: 2600, Bottom: 2700, Atomic: false, KeepWithNext: true };
48
+ const firstRow = { Top: 2700, Bottom: 2790, Atomic: true };
49
+ expect(heights([thead, firstRow])[0]).toBe(2600);
50
+ });
51
+ it('drops the layout rules before giving up when they would leave the page nearly empty', () => {
52
+ // A chart welded to the cards around it: the layout rules chain the cut up to 150px; the never-split
53
+ // rule alone stops it at the top of the row it falls in.
54
+ const blocks = [
55
+ { Top: 150, Bottom: 2900, Atomic: false }, { Top: 2700, Bottom: 2800, Atomic: true },
56
+ { Top: 100, Bottom: 2800, Atomic: false },
57
+ ];
58
+ expect(heights(blocks)[0]).toBe(2700);
59
+ });
60
+ it('shrinks a page to fit when keeping a chart together would leave it mostly empty', () => {
61
+ // a 1500px chart at 1300 overshoots the 2770px page; a page 20% taller (3324px) holds it
62
+ const plan = PlanPdfPages(1900, 5000, 'portrait', [{ Top: 1300, Bottom: 2800, Atomic: true }, { Top: 2800, Bottom: 3324, Atomic: false }]);
63
+ const first = plan.Slices[0];
64
+ expect(first.SourceHeight).toBe(3324);
65
+ expect(first.DrawHeightMM).toBeCloseTo(277); // scaled down to the printable height
66
+ expect(first.DrawWidthMM).toBeCloseTo(190 * 2770 / 3324); // and narrower, centred
67
+ expect(first.XMM).toBeCloseTo(10 + (190 - first.DrawWidthMM) / 2);
68
+ });
69
+ it('folds a sliver that would be alone on the last page into a shrunk page', () => {
70
+ // 2900px of content: 130px (a couple of rows) would carry onto page 2
71
+ expect(PlanPdfPages(1900, 2900, 'portrait').Slices.map(s => s.SourceHeight)).toEqual([2900]);
72
+ });
73
+ it('does not shrink a page that is already mostly full', () => {
74
+ const plan = PlanPdfPages(1900, 5000, 'portrait', [{ Top: 2300, Bottom: 2900, Atomic: true }]);
75
+ expect(plan.Slices[0]).toMatchObject({ SourceHeight: 2300, DrawWidthMM: 190, XMM: 10 });
76
+ });
77
+ it('cuts on whole pixels when element positions are fractional', () => {
78
+ const slices = PlanPdfPages(1900, 5000, 'portrait', [{ Top: 2700.40625, Bottom: 2790.2, Atomic: true }]).Slices;
79
+ expect(slices.map(s => s.SourceHeight)).toEqual([2700, 2300]);
80
+ expect(slices.every(s => Number.isInteger(s.SourceY) && Number.isInteger(s.SourceHeight))).toBe(true);
81
+ });
82
+ it('cuts where the page ends when moving the break would leave the page nearly empty', () => {
83
+ expect(heights([{ Top: 100, Bottom: 2800, Atomic: true }])[0]).toBe(2770);
84
+ });
85
+ });
86
+ describe('PageLayoutWidth', () => {
87
+ it('is the printable width at 96 dpi: 190mm portrait, 277mm landscape', () => {
88
+ expect(PageLayoutWidth('portrait')).toBe(718);
89
+ expect(PageLayoutWidth('landscape')).toBe(1047);
90
+ });
91
+ it('is applied to the root by PinLayoutWidth and removed on restore', () => {
92
+ document.body.innerHTML = '<div id="root" style="height: 100%"></div>';
93
+ const root = document.getElementById('root');
94
+ const restore = PinLayoutWidth(root, PageLayoutWidth('portrait'));
95
+ expect(root.style.width).toBe('718px');
96
+ expect(root.style.position).toBe('absolute'); // out of the host's flow, so its width cannot widen the panes
97
+ restore();
98
+ expect(root.style.cssText).toBe('height: 100%;');
99
+ });
100
+ });
101
+ describe('PdfFileName', () => {
102
+ it('names the file <title>_<date>.pdf with unsafe characters replaced', () => {
103
+ expect(PdfFileName('Revenue / Month: 2026', new Date(2026, 10, 5))).toBe('Revenue _ Month_ 2026_2026-11-05.pdf');
104
+ expect(PdfFileName(undefined, new Date(2026, 0, 9))).toBe('component_2026-01-09.pdf');
105
+ });
106
+ });
107
+ describe('EnterPrintMode', () => {
108
+ it('grows the root at its width, expands clipping elements, leaves the host alone, then restores', () => {
109
+ document.body.innerHTML = `
110
+ <div id="pane" style="height: 400px; overflow: auto">
111
+ <div id="root" style="height: 100%">
112
+ <div id="column" style="display: flex; flex-direction: column; height: 300px">
113
+ <div id="card" style="height: 250px; overflow: visible">
114
+ <div id="scroller" style="height: 200px; overflow-y: auto"></div>
115
+ </div>
116
+ </div>
117
+ <div id="row" style="display: flex">
118
+ <div id="row-scroller" style="height: 100px; overflow-y: auto"></div>
119
+ </div>
120
+ <div id="overlay-host" style="height: 50px; overflow: visible"></div>
121
+ </div>
122
+ </div>`;
123
+ const get = (id) => document.getElementById(id);
124
+ const root = get('root');
125
+ root.getBoundingClientRect = () => ({ width: 640 });
126
+ setHeights(get('scroller'), 900, 200); // clips its rows
127
+ setHeights(get('card'), 1000, 250); // spills once the scroller grows
128
+ setHeights(get('row-scroller'), 300, 100);
129
+ setHeights(get('overlay-host'), 120, 50); // an absolutely positioned overlay pokes out; not a clipper's ancestor
130
+ const restore = EnterPrintMode(root);
131
+ expect(get('pane').style.cssText).toBe('height: 400px; overflow: auto;');
132
+ expect(root.style.width).toBe('640px');
133
+ expect(root.style.height).toBe('auto');
134
+ expect(get('scroller').style.height).toBe('auto');
135
+ expect(get('scroller').style.overflowY).toBe('visible');
136
+ expect(get('card').style.height).toBe('auto');
137
+ expect(get('card').style.flex).toMatch(/^(none|0 0 auto)$/); // in a column flex: flex: none
138
+ expect(get('row-scroller').style.height).toBe('auto');
139
+ expect(get('row-scroller').style.flex).toBe(''); // in a row flex: left alone
140
+ expect(get('overlay-host').style.height).toBe('50px');
141
+ restore();
142
+ expect(root.style.cssText).toBe('height: 100%;');
143
+ expect(get('scroller').style.cssText).toBe('height: 200px; overflow-y: auto;');
144
+ expect(get('card').style.cssText).toBe('height: 250px; overflow: visible;');
145
+ expect(get('row-scroller').style.cssText).toBe('height: 100px; overflow-y: auto;');
146
+ });
147
+ });
148
+ describe('EnterPrintMode horizontal scrollers', () => {
149
+ it('releases a sideways scroller so no column is lost, but never an ellipsis cell', () => {
150
+ document.body.innerHTML = `
151
+ <div id="root">
152
+ <div id="grid-scroll" style="overflow-x: auto; contain: inline-size"><table></table></div>
153
+ <div id="ellipsis" style="overflow: hidden; white-space: nowrap; width: 80px">a very long cell value</div>
154
+ </div>`;
155
+ const get = (id) => document.getElementById(id);
156
+ get('root').getBoundingClientRect = () => ({ width: 718 });
157
+ for (const id of ['grid-scroll', 'ellipsis']) {
158
+ Object.defineProperty(get(id), 'scrollWidth', { configurable: true, get: () => 1100 });
159
+ Object.defineProperty(get(id), 'clientWidth', { configurable: true, get: () => 600 });
160
+ }
161
+ const restore = EnterPrintMode(get('root'));
162
+ expect(get('grid-scroll').style.overflowX).toBe('visible');
163
+ expect(get('grid-scroll').style.contain).toBe('none');
164
+ expect(get('ellipsis').style.overflow).toBe('hidden');
165
+ restore();
166
+ expect(get('grid-scroll').style.cssText).toBe('overflow-x: auto; contain: inline-size;');
167
+ });
168
+ });
169
+ describe('TableLeadBlock', () => {
170
+ it('spans from the card title through the header row to the first data row, but not past the lead limit', () => {
171
+ document.body.innerHTML = `
172
+ <div id="root"><div id="page-section"><div id="card"><h3>Member Directory</h3><input/>
173
+ <div id="grid"><table><thead><tr><th>Name</th></tr></thead><tbody><tr id="r1"><td>a</td></tr></tbody></table></div></div></div></div>`;
174
+ const tops = { 'page-section': [0, 2000], card: [700, 1600], grid: [800, 1600], r1: [860, 900] };
175
+ for (const [id, [top, bottom]] of Object.entries(tops)) {
176
+ document.getElementById(id).getBoundingClientRect = () => ({ top, bottom, height: bottom - top });
177
+ }
178
+ const table = document.querySelector('table');
179
+ table.getBoundingClientRect = () => ({ top: 820, bottom: 1600, height: 780 });
180
+ // the card starts 120px above the table (within 200), the page section 820px above (beyond it)
181
+ expect(TableLeadBlock(table, document.getElementById('root'), 200)).toEqual({ top: 700, bottom: 900 });
182
+ });
183
+ it('walks past box-less wrappers (display: contents) instead of stopping at them', () => {
184
+ document.body.innerHTML = `
185
+ <div id="root"><div id="card"><h3>Member Directory</h3>
186
+ <div id="contents" style="display: contents"><div id="grid"><table><tbody><tr id="r1"><td>a</td></tr></tbody></table></div></div></div></div>`;
187
+ const rects = { card: [700, 1600, 600], contents: [0, 0, 0], grid: [800, 1600, 600], r1: [860, 900, 600] };
188
+ for (const [id, [top, bottom, width]] of Object.entries(rects)) {
189
+ document.getElementById(id).getBoundingClientRect = () => ({ top, bottom, width, height: bottom - top });
190
+ }
191
+ const table = document.querySelector('table');
192
+ table.getBoundingClientRect = () => ({ top: 820, bottom: 1600, width: 600, height: 780 });
193
+ expect(TableLeadBlock(table, document.getElementById('root'), 200)).toEqual({ top: 700, bottom: 900 });
194
+ });
195
+ });
196
+ describe('HorizontalOverflow', () => {
197
+ it('measures content running past its card even when the root is not wider, ignoring ellipsis cells', () => {
198
+ document.body.innerHTML = `
199
+ <div id="root"><div id="card" style="padding: 12px"><table><tr><td>a</td></tr></table></div>
200
+ <div id="ellipsis" style="overflow: hidden"><span>a long truncated value</span></div></div>`;
201
+ const set = (id, scroll, client) => {
202
+ const el = document.getElementById(id);
203
+ Object.defineProperty(el, 'scrollWidth', { configurable: true, get: () => scroll });
204
+ Object.defineProperty(el, 'clientWidth', { configurable: true, get: () => client });
205
+ };
206
+ set('root', 718, 718);
207
+ set('card', 925, 718); // the table spills 207px into and past the card's padding
208
+ set('ellipsis', 2000, 300); // clips on purpose
209
+ expect(HorizontalOverflow(document.getElementById('root'))).toBe(207);
210
+ });
211
+ });
212
+ describe('SharpenCharts', () => {
213
+ it('re-renders Chart.js charts at a capture pixel ratio without animation, then restores them', () => {
214
+ const chart = { options: { devicePixelRatio: 1, animation: true }, resize: vi.fn(), update: vi.fn() };
215
+ const win = { Chart: { instances: { a: chart } } };
216
+ const restore = SharpenCharts(win);
217
+ expect(chart.options).toEqual({ devicePixelRatio: 3, animation: false });
218
+ expect(chart.update).toHaveBeenCalledWith('none');
219
+ restore();
220
+ expect(chart.options).toEqual({ devicePixelRatio: 1, animation: true });
221
+ expect(chart.resize).toHaveBeenCalledTimes(2);
222
+ });
223
+ it('does nothing when the page has not loaded Chart.js', () => {
224
+ expect(() => SharpenCharts({})()).not.toThrow();
225
+ });
226
+ });
227
+ describe('BlendBackgrounds', () => {
228
+ const dark = { R: 15, G: 23, B: 42, A: 255 };
229
+ it('is white when nothing behind the component paints a background', () => {
230
+ expect(BlendBackgrounds([])).toEqual({ R: 255, G: 255, B: 255, A: 255 });
231
+ });
232
+ it('is the nearest opaque background, so a dark surface stays dark', () => {
233
+ expect(BlendBackgrounds([dark, { R: 255, G: 255, B: 255, A: 255 }])).toEqual(dark);
234
+ });
235
+ it('blends a translucent layer over the background behind it', () => {
236
+ expect(BlendBackgrounds([{ R: 255, G: 255, B: 255, A: 128 }, { R: 0, G: 0, B: 0, A: 255 }])).toEqual({ R: 128, G: 128, B: 128, A: 255 });
237
+ });
238
+ it('blends a translucent layer over white when no layer is opaque', () => {
239
+ expect(BlendBackgrounds([{ R: 0, G: 0, B: 0, A: 51 }])).toEqual({ R: 204, G: 204, B: 204, A: 255 });
240
+ });
241
+ });
242
+ describe('IsBlankPixels', () => {
243
+ const dark = { R: 15, G: 23, B: 42, A: 255 };
244
+ const fill = (count, [r, g, b]) => {
245
+ const pixels = new Uint8ClampedArray(count * 4);
246
+ for (let i = 0; i < pixels.length; i += 4) {
247
+ pixels.set([r, g, b, 255], i);
248
+ }
249
+ return pixels;
250
+ };
251
+ it('counts a band of the dark background, or near it, as blank', () => {
252
+ expect(IsBlankPixels(fill(70, [15, 23, 42]), dark)).toBe(true);
253
+ expect(IsBlankPixels(fill(70, [20, 28, 47]), dark)).toBe(true);
254
+ });
255
+ it('does not count a white band as blank on a dark background, nor a dark band on white', () => {
256
+ expect(IsBlankPixels(fill(70, [255, 255, 255]), dark)).toBe(false);
257
+ expect(IsBlankPixels(fill(70, [15, 23, 42]), { R: 255, G: 255, B: 255, A: 255 })).toBe(false);
258
+ });
259
+ it('sees content that differs from the background', () => {
260
+ const pixels = fill(70, [15, 23, 42]);
261
+ pixels.set([241, 245, 249, 255], 0);
262
+ expect(IsBlankPixels(pixels, dark)).toBe(false);
263
+ });
264
+ });
265
+ //# sourceMappingURL=component-pdf-export.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-pdf-export.test.js","sourceRoot":"","sources":["../../src/__tests__/component-pdf-export.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpN,iGAAiG;AACjG,SAAS,UAAU,CAAC,OAAoB,EAAE,YAAoB,EAAE,YAAoB;IAChF,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG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C,CAAC;QACpC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import { describe, it, expect, vi } from 'vitest';\nimport { BlendBackgrounds, EnterPrintMode, HorizontalOverflow, IsBlankPixels, PageLayoutWidth, PdfFileName, PinLayoutWidth, PlanPdfPages, SharpenCharts, TableLeadBlock } from '../lib/export/component-pdf-export';\n\n/** jsdom has no layout: give an element the scroll and client heights a browser would report. */\nfunction setHeights(element: HTMLElement, scrollHeight: number, clientHeight: number): void {\n Object.defineProperty(element, 'scrollHeight', { configurable: true, get: () => scrollHeight });\n Object.defineProperty(element, 'clientHeight', { configurable: true, get: () => clientHeight });\n}\n\ndescribe('PlanPdfPages', () => {\n it('fits a tall capture to the A4 portrait width and cuts it into page-height bands', () => {\n const plan = PlanPdfPages(1900, 5000);\n expect(plan).toMatchObject({ Orientation: 'portrait', PageWidthMM: 210, PageHeightMM: 297, DrawWidthMM: 190 });\n // 277mm of usable height at 190mm / 1900px = 0.1 mm per pixel\n expect(plan.Slices.map(s => [s.SourceY, s.SourceHeight])).toEqual([[0, 2770], [2770, 2230]]);\n expect(plan.Slices[1].DrawHeightMM).toBeCloseTo(223);\n });\n\n it('uses the requested orientation, and one page when the capture fits', () => {\n const plan = PlanPdfPages(3000, 1000, 'landscape');\n expect(plan.Orientation).toBe('landscape');\n expect(plan.Slices).toHaveLength(1);\n expect(plan.Slices[0]).toMatchObject({ SourceY: 0, SourceHeight: 1000 });\n });\n});\n\ndescribe('PlanPdfPages page breaks', () => {\n // 1900px wide: a page holds 2770px (0.1 mm per pixel on 190mm)\n const heights = (blocks: Parameters<typeof PlanPdfPages>[3]) =>\n PlanPdfPages(1900, 5000, 'portrait', blocks).Slices.map(s => s.SourceHeight);\n\n it('moves a cut to the top of a row or chart it would split, however far back, when it fits a page', () => {\n expect(heights([{ Top: 2700, Bottom: 2800, Atomic: true }])).toEqual([2700, 2300]);\n // a 2200px chart starting at 1300 that even a shrunk page cannot hold: the page ends at its top\n expect(heights([{ Top: 1300, Bottom: 3500, Atomic: true }])[0]).toBe(1300);\n });\n\n it('splits a large card between its children, but moves it whole when only its header would stay behind', () => {\n const card = { Top: 1000, Bottom: 3500, Atomic: false };\n const rows = [{ Top: 2700, Bottom: 2790, Atomic: true }];\n expect(heights([card, ...rows])[0]).toBe(2700); // split between rows inside the card\n const lateCard = { Top: 2400, Bottom: 3800, Atomic: false }; // only 370px (< 15% of a page) above the cut: its title\n expect(heights([lateCard])[0]).toBe(2400);\n });\n\n it('keeps small containers together and splits anything taller than a page', () => {\n expect(heights([{ Top: 2650, Bottom: 2900, Atomic: false }])[0]).toBe(2650); // a KPI tile: < 15% of a page\n expect(heights([{ Top: 500, Bottom: 3400, Atomic: true }])[0]).toBe(2770); // taller than a page\n });\n\n it('moves a card that fits a page whole when only its last lines would carry over', () => {\n // 130px (< 15% of a page) would carry over; moving the card leaves the page 83% full, so no shrink\n expect(heights([{ Top: 2300, Bottom: 2900, Atomic: false }])[0]).toBe(2300);\n });\n\n it('keeps a table header row or heading on the page of what follows it', () => {\n const thead = { Top: 2600, Bottom: 2700, Atomic: false, KeepWithNext: true };\n const firstRow = { Top: 2700, Bottom: 2790, Atomic: true };\n expect(heights([thead, firstRow])[0]).toBe(2600);\n });\n\n it('drops the layout rules before giving up when they would leave the page nearly empty', () => {\n // A chart welded to the cards around it: the layout rules chain the cut up to 150px; the never-split\n // rule alone stops it at the top of the row it falls in.\n const blocks = [\n { Top: 150, Bottom: 2900, Atomic: false }, { Top: 2700, Bottom: 2800, Atomic: true },\n { Top: 100, Bottom: 2800, Atomic: false },\n ];\n expect(heights(blocks)[0]).toBe(2700);\n });\n\n it('shrinks a page to fit when keeping a chart together would leave it mostly empty', () => {\n // a 1500px chart at 1300 overshoots the 2770px page; a page 20% taller (3324px) holds it\n const plan = PlanPdfPages(1900, 5000, 'portrait', [{ Top: 1300, Bottom: 2800, Atomic: true }, { Top: 2800, Bottom: 3324, Atomic: false }]);\n const first = plan.Slices[0];\n expect(first.SourceHeight).toBe(3324);\n expect(first.DrawHeightMM).toBeCloseTo(277); // scaled down to the printable height\n expect(first.DrawWidthMM).toBeCloseTo(190 * 2770 / 3324); // and narrower, centred\n expect(first.XMM).toBeCloseTo(10 + (190 - first.DrawWidthMM) / 2);\n });\n\n it('folds a sliver that would be alone on the last page into a shrunk page', () => {\n // 2900px of content: 130px (a couple of rows) would carry onto page 2\n expect(PlanPdfPages(1900, 2900, 'portrait').Slices.map(s => s.SourceHeight)).toEqual([2900]);\n });\n\n it('does not shrink a page that is already mostly full', () => {\n const plan = PlanPdfPages(1900, 5000, 'portrait', [{ Top: 2300, Bottom: 2900, Atomic: true }]);\n expect(plan.Slices[0]).toMatchObject({ SourceHeight: 2300, DrawWidthMM: 190, XMM: 10 });\n });\n\n it('cuts on whole pixels when element positions are fractional', () => {\n const slices = PlanPdfPages(1900, 5000, 'portrait', [{ Top: 2700.40625, Bottom: 2790.2, Atomic: true }]).Slices;\n expect(slices.map(s => s.SourceHeight)).toEqual([2700, 2300]);\n expect(slices.every(s => Number.isInteger(s.SourceY) && Number.isInteger(s.SourceHeight))).toBe(true);\n });\n\n it('cuts where the page ends when moving the break would leave the page nearly empty', () => {\n expect(heights([{ Top: 100, Bottom: 2800, Atomic: true }])[0]).toBe(2770);\n });\n});\n\ndescribe('PageLayoutWidth', () => {\n it('is the printable width at 96 dpi: 190mm portrait, 277mm landscape', () => {\n expect(PageLayoutWidth('portrait')).toBe(718);\n expect(PageLayoutWidth('landscape')).toBe(1047);\n });\n\n it('is applied to the root by PinLayoutWidth and removed on restore', () => {\n document.body.innerHTML = '<div id=\"root\" style=\"height: 100%\"></div>';\n const root = document.getElementById('root') as HTMLElement;\n const restore = PinLayoutWidth(root, PageLayoutWidth('portrait'));\n expect(root.style.width).toBe('718px');\n expect(root.style.position).toBe('absolute'); // out of the host's flow, so its width cannot widen the panes\n restore();\n expect(root.style.cssText).toBe('height: 100%;');\n });\n});\n\ndescribe('PdfFileName', () => {\n it('names the file <title>_<date>.pdf with unsafe characters replaced', () => {\n expect(PdfFileName('Revenue / Month: 2026', new Date(2026, 10, 5))).toBe('Revenue _ Month_ 2026_2026-11-05.pdf');\n expect(PdfFileName(undefined, new Date(2026, 0, 9))).toBe('component_2026-01-09.pdf');\n });\n});\n\ndescribe('EnterPrintMode', () => {\n it('grows the root at its width, expands clipping elements, leaves the host alone, then restores', () => {\n document.body.innerHTML = `\n <div id=\"pane\" style=\"height: 400px; overflow: auto\">\n <div id=\"root\" style=\"height: 100%\">\n <div id=\"column\" style=\"display: flex; flex-direction: column; height: 300px\">\n <div id=\"card\" style=\"height: 250px; overflow: visible\">\n <div id=\"scroller\" style=\"height: 200px; overflow-y: auto\"></div>\n </div>\n </div>\n <div id=\"row\" style=\"display: flex\">\n <div id=\"row-scroller\" style=\"height: 100px; overflow-y: auto\"></div>\n </div>\n <div id=\"overlay-host\" style=\"height: 50px; overflow: visible\"></div>\n </div>\n </div>`;\n const get = (id: string) => document.getElementById(id) as HTMLElement;\n const root = get('root');\n root.getBoundingClientRect = () => ({ width: 640 } as DOMRect);\n setHeights(get('scroller'), 900, 200); // clips its rows\n setHeights(get('card'), 1000, 250); // spills once the scroller grows\n setHeights(get('row-scroller'), 300, 100);\n setHeights(get('overlay-host'), 120, 50); // an absolutely positioned overlay pokes out; not a clipper's ancestor\n\n const restore = EnterPrintMode(root);\n expect(get('pane').style.cssText).toBe('height: 400px; overflow: auto;');\n expect(root.style.width).toBe('640px');\n expect(root.style.height).toBe('auto');\n expect(get('scroller').style.height).toBe('auto');\n expect(get('scroller').style.overflowY).toBe('visible');\n expect(get('card').style.height).toBe('auto');\n expect(get('card').style.flex).toMatch(/^(none|0 0 auto)$/); // in a column flex: flex: none\n expect(get('row-scroller').style.height).toBe('auto');\n expect(get('row-scroller').style.flex).toBe(''); // in a row flex: left alone\n expect(get('overlay-host').style.height).toBe('50px');\n\n restore();\n expect(root.style.cssText).toBe('height: 100%;');\n expect(get('scroller').style.cssText).toBe('height: 200px; overflow-y: auto;');\n expect(get('card').style.cssText).toBe('height: 250px; overflow: visible;');\n expect(get('row-scroller').style.cssText).toBe('height: 100px; overflow-y: auto;');\n });\n});\n\ndescribe('EnterPrintMode horizontal scrollers', () => {\n it('releases a sideways scroller so no column is lost, but never an ellipsis cell', () => {\n document.body.innerHTML = `\n <div id=\"root\">\n <div id=\"grid-scroll\" style=\"overflow-x: auto; contain: inline-size\"><table></table></div>\n <div id=\"ellipsis\" style=\"overflow: hidden; white-space: nowrap; width: 80px\">a very long cell value</div>\n </div>`;\n const get = (id: string) => document.getElementById(id) as HTMLElement;\n get('root').getBoundingClientRect = () => ({ width: 718 } as DOMRect);\n for (const id of ['grid-scroll', 'ellipsis']) {\n Object.defineProperty(get(id), 'scrollWidth', { configurable: true, get: () => 1100 });\n Object.defineProperty(get(id), 'clientWidth', { configurable: true, get: () => 600 });\n }\n const restore = EnterPrintMode(get('root'));\n expect(get('grid-scroll').style.overflowX).toBe('visible');\n expect(get('grid-scroll').style.contain).toBe('none');\n expect(get('ellipsis').style.overflow).toBe('hidden');\n restore();\n expect(get('grid-scroll').style.cssText).toBe('overflow-x: auto; contain: inline-size;');\n });\n});\n\ndescribe('TableLeadBlock', () => {\n it('spans from the card title through the header row to the first data row, but not past the lead limit', () => {\n document.body.innerHTML = `\n <div id=\"root\"><div id=\"page-section\"><div id=\"card\"><h3>Member Directory</h3><input/>\n <div id=\"grid\"><table><thead><tr><th>Name</th></tr></thead><tbody><tr id=\"r1\"><td>a</td></tr></tbody></table></div></div></div></div>`;\n const tops: Record<string, [number, number]> = { 'page-section': [0, 2000], card: [700, 1600], grid: [800, 1600], r1: [860, 900] };\n for (const [id, [top, bottom]] of Object.entries(tops)) {\n (document.getElementById(id) as HTMLElement).getBoundingClientRect = () => ({ top, bottom, height: bottom - top } as DOMRect);\n }\n const table = document.querySelector('table') as HTMLTableElement;\n table.getBoundingClientRect = () => ({ top: 820, bottom: 1600, height: 780 } as DOMRect);\n // the card starts 120px above the table (within 200), the page section 820px above (beyond it)\n expect(TableLeadBlock(table, document.getElementById('root') as HTMLElement, 200)).toEqual({ top: 700, bottom: 900 });\n });\n\n it('walks past box-less wrappers (display: contents) instead of stopping at them', () => {\n document.body.innerHTML = `\n <div id=\"root\"><div id=\"card\"><h3>Member Directory</h3>\n <div id=\"contents\" style=\"display: contents\"><div id=\"grid\"><table><tbody><tr id=\"r1\"><td>a</td></tr></tbody></table></div></div></div></div>`;\n const rects: Record<string, [number, number, number]> = { card: [700, 1600, 600], contents: [0, 0, 0], grid: [800, 1600, 600], r1: [860, 900, 600] };\n for (const [id, [top, bottom, width]] of Object.entries(rects)) {\n (document.getElementById(id) as HTMLElement).getBoundingClientRect = () => ({ top, bottom, width, height: bottom - top } as DOMRect);\n }\n const table = document.querySelector('table') as HTMLTableElement;\n table.getBoundingClientRect = () => ({ top: 820, bottom: 1600, width: 600, height: 780 } as DOMRect);\n expect(TableLeadBlock(table, document.getElementById('root') as HTMLElement, 200)).toEqual({ top: 700, bottom: 900 });\n });\n});\n\ndescribe('HorizontalOverflow', () => {\n it('measures content running past its card even when the root is not wider, ignoring ellipsis cells', () => {\n document.body.innerHTML = `\n <div id=\"root\"><div id=\"card\" style=\"padding: 12px\"><table><tr><td>a</td></tr></table></div>\n <div id=\"ellipsis\" style=\"overflow: hidden\"><span>a long truncated value</span></div></div>`;\n const set = (id: string, scroll: number, client: number) => {\n const el = document.getElementById(id) as HTMLElement;\n Object.defineProperty(el, 'scrollWidth', { configurable: true, get: () => scroll });\n Object.defineProperty(el, 'clientWidth', { configurable: true, get: () => client });\n };\n set('root', 718, 718);\n set('card', 925, 718); // the table spills 207px into and past the card's padding\n set('ellipsis', 2000, 300); // clips on purpose\n expect(HorizontalOverflow(document.getElementById('root') as HTMLElement)).toBe(207);\n });\n});\n\ndescribe('SharpenCharts', () => {\n it('re-renders Chart.js charts at a capture pixel ratio without animation, then restores them', () => {\n const chart = { options: { devicePixelRatio: 1, animation: true as boolean | object }, resize: vi.fn(), update: vi.fn() };\n const win = { Chart: { instances: { a: chart } } } as unknown as Window;\n const restore = SharpenCharts(win);\n expect(chart.options).toEqual({ devicePixelRatio: 3, animation: false });\n expect(chart.update).toHaveBeenCalledWith('none');\n restore();\n expect(chart.options).toEqual({ devicePixelRatio: 1, animation: true });\n expect(chart.resize).toHaveBeenCalledTimes(2);\n });\n\n it('does nothing when the page has not loaded Chart.js', () => {\n expect(() => SharpenCharts({} as Window)()).not.toThrow();\n });\n});\n\ndescribe('BlendBackgrounds', () => {\n const dark = { R: 15, G: 23, B: 42, A: 255 };\n\n it('is white when nothing behind the component paints a background', () => {\n expect(BlendBackgrounds([])).toEqual({ R: 255, G: 255, B: 255, A: 255 });\n });\n\n it('is the nearest opaque background, so a dark surface stays dark', () => {\n expect(BlendBackgrounds([dark, { R: 255, G: 255, B: 255, A: 255 }])).toEqual(dark);\n });\n\n it('blends a translucent layer over the background behind it', () => {\n expect(BlendBackgrounds([{ R: 255, G: 255, B: 255, A: 128 }, { R: 0, G: 0, B: 0, A: 255 }])).toEqual({ R: 128, G: 128, B: 128, A: 255 });\n });\n\n it('blends a translucent layer over white when no layer is opaque', () => {\n expect(BlendBackgrounds([{ R: 0, G: 0, B: 0, A: 51 }])).toEqual({ R: 204, G: 204, B: 204, A: 255 });\n });\n});\n\ndescribe('IsBlankPixels', () => {\n const dark = { R: 15, G: 23, B: 42, A: 255 };\n const fill = (count: number, [r, g, b]: [number, number, number]) => {\n const pixels = new Uint8ClampedArray(count * 4);\n for (let i = 0; i < pixels.length; i += 4) {\n pixels.set([r, g, b, 255], i);\n }\n return pixels;\n };\n\n it('counts a band of the dark background, or near it, as blank', () => {\n expect(IsBlankPixels(fill(70, [15, 23, 42]), dark)).toBe(true);\n expect(IsBlankPixels(fill(70, [20, 28, 47]), dark)).toBe(true);\n });\n\n it('does not count a white band as blank on a dark background, nor a dark band on white', () => {\n expect(IsBlankPixels(fill(70, [255, 255, 255]), dark)).toBe(false);\n expect(IsBlankPixels(fill(70, [15, 23, 42]), { R: 255, G: 255, B: 255, A: 255 })).toBe(false);\n });\n\n it('sees content that differs from the background', () => {\n const pixels = fill(70, [15, 23, 42]);\n pixels.set([241, 245, 249, 255], 0);\n expect(IsBlankPixels(pixels, dark)).toBe(false);\n });\n});\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,45 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { BuildImagePdf } from '../lib/export/image-pdf-writer';
3
+ function page(jpeg, overrides = {}) {
4
+ return {
5
+ Jpeg: new Uint8Array(jpeg), PixelWidth: 1900, PixelHeight: 2770,
6
+ PageWidthMM: 210, PageHeightMM: 297, XMM: 10, YMM: 10, DrawWidthMM: 190, DrawHeightMM: 277,
7
+ ...overrides,
8
+ };
9
+ }
10
+ /** The file as latin1 text, so byte offsets and string offsets agree. */
11
+ function asText(bytes) {
12
+ return Array.from(bytes, b => String.fromCharCode(b)).join('');
13
+ }
14
+ describe('BuildImagePdf', () => {
15
+ const pdf = BuildImagePdf([page([0xff, 0xd8, 0x01, 0xff, 0xd9]), page([0xff, 0xd8, 0x02, 0x03, 0xff, 0xd9], { PixelHeight: 100, DrawHeightMM: 10 })]);
16
+ const text = asText(pdf);
17
+ it('writes a header, a catalog and a page tree with one kid per page', () => {
18
+ expect(text.startsWith('%PDF-1.4\n')).toBe(true);
19
+ expect(text).toContain('1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>');
20
+ expect(text).toContain('<< /Type /Pages /Kids [3 0 R 6 0 R] /Count 2 >>');
21
+ expect(text.endsWith('%%EOF\n')).toBe(true);
22
+ });
23
+ it('declares the image size in whole pixels even when given fractions', () => {
24
+ const text = asText(BuildImagePdf([page([0xff, 0xd8, 0xff, 0xd9], { PixelWidth: 1598, PixelHeight: 2316.40625 })]));
25
+ expect(text).toContain('/Width 1598 /Height 2316 ');
26
+ expect(text).not.toMatch(/\/Height \d+\.\d/);
27
+ });
28
+ it('points every xref entry at its object, and startxref at the xref table', () => {
29
+ const xrefAt = Number(/startxref\n(\d+)\n/.exec(text)?.[1]);
30
+ expect(text.slice(xrefAt, xrefAt + 5)).toBe('xref\n');
31
+ const entries = text.slice(xrefAt).match(/^(\d{10}) 00000 n $/gm) ?? [];
32
+ expect(entries).toHaveLength(8); // catalog, pages, 3 objects for each of 2 pages
33
+ entries.forEach((entry, index) => {
34
+ const offset = Number(entry.slice(0, 10));
35
+ expect(text.slice(offset, offset + `${index + 1} 0 obj`.length)).toBe(`${index + 1} 0 obj`);
36
+ });
37
+ });
38
+ it('embeds each JPEG unchanged with its size and draws it in points from the bottom left', () => {
39
+ expect(text).toContain('/Width 1900 /Height 2770 /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length 5 >>\nstream\n\xff\xd8\x01\xff\xd9\nendstream');
40
+ // 190mm x 277mm at (10mm, 297 - 10 - 277 = 10mm)
41
+ expect(text).toContain('q 538.58 0 0 785.20 28.35 28.35 cm /Im0 Do Q');
42
+ expect(text).toContain('/MediaBox [0 0 595.28 841.89]');
43
+ });
44
+ });
45
+ //# sourceMappingURL=image-pdf-writer.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-pdf-writer.test.js","sourceRoot":"","sources":["../../src/__tests__/image-pdf-writer.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAgB,MAAM,gCAAgC,CAAC;AAE7E,SAAS,IAAI,CAAC,IAAc,EAAE,YAAmC,EAAE;IAC/D,OAAO;QACH,IAAI,EAAE,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI;QAC/D,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,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5F,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,8IAA8I,CAAC,CAAC;QACvK,iDAAiD;QACjD,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,8CAA8C,CAAC,CAAC;QACvE,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,+BAA+B,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import { describe, it, expect } from 'vitest';\nimport { BuildImagePdf, PdfImagePage } from '../lib/export/image-pdf-writer';\n\nfunction page(jpeg: number[], overrides: Partial<PdfImagePage> = {}): PdfImagePage {\n return {\n Jpeg: new Uint8Array(jpeg), PixelWidth: 1900, PixelHeight: 2770,\n PageWidthMM: 210, PageHeightMM: 297, XMM: 10, YMM: 10, DrawWidthMM: 190, DrawHeightMM: 277,\n ...overrides,\n };\n}\n\n/** The file as latin1 text, so byte offsets and string offsets agree. */\nfunction asText(bytes: Uint8Array): string {\n return Array.from(bytes, b => String.fromCharCode(b)).join('');\n}\n\ndescribe('BuildImagePdf', () => {\n const pdf = BuildImagePdf([page([0xff, 0xd8, 0x01, 0xff, 0xd9]), page([0xff, 0xd8, 0x02, 0x03, 0xff, 0xd9], { PixelHeight: 100, DrawHeightMM: 10 })]);\n const text = asText(pdf);\n\n it('writes a header, a catalog and a page tree with one kid per page', () => {\n expect(text.startsWith('%PDF-1.4\\n')).toBe(true);\n expect(text).toContain('1 0 obj\\n<< /Type /Catalog /Pages 2 0 R >>');\n expect(text).toContain('<< /Type /Pages /Kids [3 0 R 6 0 R] /Count 2 >>');\n expect(text.endsWith('%%EOF\\n')).toBe(true);\n });\n\n it('declares the image size in whole pixels even when given fractions', () => {\n const text = asText(BuildImagePdf([page([0xff, 0xd8, 0xff, 0xd9], { PixelWidth: 1598, PixelHeight: 2316.40625 })]));\n expect(text).toContain('/Width 1598 /Height 2316 ');\n expect(text).not.toMatch(/\\/Height \\d+\\.\\d/);\n });\n\n it('points every xref entry at its object, and startxref at the xref table', () => {\n const xrefAt = Number(/startxref\\n(\\d+)\\n/.exec(text)?.[1]);\n expect(text.slice(xrefAt, xrefAt + 5)).toBe('xref\\n');\n const entries = text.slice(xrefAt).match(/^(\\d{10}) 00000 n $/gm) ?? [];\n expect(entries).toHaveLength(8); // catalog, pages, 3 objects for each of 2 pages\n entries.forEach((entry, index) => {\n const offset = Number(entry.slice(0, 10));\n expect(text.slice(offset, offset + `${index + 1} 0 obj`.length)).toBe(`${index + 1} 0 obj`);\n });\n });\n\n it('embeds each JPEG unchanged with its size and draws it in points from the bottom left', () => {\n expect(text).toContain('/Width 1900 /Height 2770 /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length 5 >>\\nstream\\n\\xff\\xd8\\x01\\xff\\xd9\\nendstream');\n // 190mm x 277mm at (10mm, 297 - 10 - 277 = 10mm)\n expect(text).toContain('q 538.58 0 0 785.20 28.35 28.35 cm /Im0 Do Q');\n expect(text).toContain('/MediaBox [0 0 595.28 841.89]');\n });\n});\n"]}
@@ -10,6 +10,7 @@ import { ReactBridgeService } from '../services/react-bridge.service';
10
10
  import { AngularAdapterService } from '../services/angular-adapter.service';
11
11
  import { CompositeKey, DataSnapshot } from '@memberjunction/core';
12
12
  import { MJNotificationService } from '@memberjunction/ng-notifications';
13
+ import { PdfOrientation } from '../export/component-pdf-export';
13
14
  import * as i0 from "@angular/core";
14
15
  /**
15
16
  * Event emitted by React components
@@ -242,6 +243,15 @@ export declare class MJReactComponent extends BaseAngularComponent implements Af
242
243
  * Only populated after successful component initialization.
243
244
  */
244
245
  ResolvedComponentSpec: ComponentSpec | null;
246
+ /**
247
+ * Downloads the rendered component as a PDF: everything it shows in its current state (filters,
248
+ * selections, grid pages), including content behind inner scrollbars, laid out at the A4 page's
249
+ * printable width in the given orientation. Content in portals (antd modals, drawers) is not included.
250
+ *
251
+ * @param orientation A4 portrait (default) or landscape.
252
+ * @param title File name stem; defaults to the component spec's title or name.
253
+ */
254
+ CapturePDF(orientation?: PdfOrientation, title?: string): Promise<void>;
245
255
  /** @deprecated Use {@link ResolvedComponentSpec}. */
246
256
  get resolvedComponentSpec(): ComponentSpec | null;
247
257
  /** @deprecated Use {@link ResolvedComponentSpec}. */
@@ -13,6 +13,7 @@ import { createErrorBoundary, ComponentHierarchyRegistrar, resourceManager, reac
13
13
  import { LogError, DataSnapshot, DataTable, MJColumnDescriptor } from '@memberjunction/core';
14
14
  import { MJNotificationService } from '@memberjunction/ng-notifications';
15
15
  import { ComponentMetadataEngine, UserInfoEngine } from '@memberjunction/core-entities';
16
+ import { ExportComponentToPDF } from '../export/component-pdf-export';
16
17
  import * as i0 from "@angular/core";
17
18
  import * as i1 from "../services/react-bridge.service";
18
19
  import * as i2 from "../services/angular-adapter.service";
@@ -251,6 +252,18 @@ export class MJReactComponent extends BaseAngularComponent {
251
252
  set hasError(value) {
252
253
  this.HasError = value;
253
254
  }
255
+ /**
256
+ * Downloads the rendered component as a PDF: everything it shows in its current state (filters,
257
+ * selections, grid pages), including content behind inner scrollbars, laid out at the A4 page's
258
+ * printable width in the given orientation. Content in portals (antd modals, drawers) is not included.
259
+ *
260
+ * @param orientation A4 portrait (default) or landscape.
261
+ * @param title File name stem; defaults to the component spec's title or name.
262
+ */
263
+ async CapturePDF(orientation = 'portrait', title) {
264
+ const spec = this.ResolvedComponentSpec;
265
+ await ExportComponentToPDF(this.Container.nativeElement, title ?? spec?.title ?? spec?.name, orientation);
266
+ }
254
267
  /** @deprecated Use {@link ResolvedComponentSpec}. */
255
268
  get resolvedComponentSpec() {
256
269
  return this.ResolvedComponentSpec;
@@ -1414,5 +1427,5 @@ export class MJReactComponent extends BaseAngularComponent {
1414
1427
  type: ViewChild,
1415
1428
  args: ['container', { read: ElementRef, static: true }]
1416
1429
  }] }); })();
1417
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MJReactComponent, { className: "MJReactComponent", filePath: "lib/components/mj-react-component.component.ts", lineNumber: 161 }); })();
1430
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MJReactComponent, { className: "MJReactComponent", filePath: "lib/components/mj-react-component.component.ts", lineNumber: 162 }); })();
1418
1431
  //# sourceMappingURL=mj-react-component.component.js.map