@embedpdf/plugin-render 1.4.1 → 1.5.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.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),r=class extends e.BasePlugin{constructor(r,t){super(r,t),this.refreshPages$=e.createEmitter(),this.coreStore.onAction(e.REFRESH_PAGES,(e=>{this.refreshPages$.emit(e.payload)}))}async initialize(e){}buildCapability(){return{renderPage:this.renderPage.bind(this),renderPageRect:this.renderPageRect.bind(this)}}onRefreshPages(e){return this.refreshPages$.on(e)}renderPage({pageIndex:e,options:r}){const t=this.coreState.core;if(!t.document)throw new Error("document does not open");const n=t.document.pages.find((r=>r.index===e));if(!n)throw new Error("page does not exist");return this.engine.renderPage(t.document,n,r)}renderPageRect({pageIndex:e,rect:r,options:t}){const n=this.coreState.core;if(!n.document)throw new Error("document does not open");const o=n.document.pages.find((r=>r.index===e));if(!o)throw new Error("page does not exist");return this.engine.renderPageRect(n.document,o,r,t)}};r.id="render";let t=r;const n="render",o={manifest:{id:n,name:"Render Plugin",version:"1.0.0",provides:["render"],requires:[],optional:[],defaultConfig:{enabled:!0}},create:e=>new t(n,e),reducer:()=>{},initialState:{}};exports.RenderPlugin=t,exports.RenderPluginPackage=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=class extends e.BasePlugin{constructor(t,n){super(t,n),this.refreshPages$=e.createEmitter(),this.withForms=!1,this.withAnnotations=!1,this.coreStore.onAction(e.REFRESH_PAGES,(e=>{this.refreshPages$.emit(e.payload)}))}async initialize(e){this.withForms=e.withForms??!1,this.withAnnotations=e.withAnnotations??!1}buildCapability(){return{renderPage:this.renderPage.bind(this),renderPageRect:this.renderPageRect.bind(this)}}onRefreshPages(e){return this.refreshPages$.on(e)}renderPage({pageIndex:e,options:t}){const n=this.coreState.core;if(!n.document)throw new Error("document does not open");const i=n.document.pages.find((t=>t.index===e));if(!i)throw new Error("page does not exist");const o={...t??{},withForms:(null==t?void 0:t.withForms)??this.withForms,withAnnotations:(null==t?void 0:t.withAnnotations)??this.withAnnotations};return this.engine.renderPage(n.document,i,o)}renderPageRect({pageIndex:e,rect:t,options:n}){const i=this.coreState.core;if(!i.document)throw new Error("document does not open");const o=i.document.pages.find((t=>t.index===e));if(!o)throw new Error("page does not exist");const r={...n??{},withForms:(null==n?void 0:n.withForms)??this.withForms,withAnnotations:(null==n?void 0:n.withAnnotations)??this.withAnnotations};return this.engine.renderPageRect(i.document,o,t,r)}};t.id="render";let n=t;const i="render",o={manifest:{id:i,name:"Render Plugin",version:"1.0.0",provides:["render"],requires:[],optional:[],defaultConfig:{enabled:!0}},create:e=>new n(i,e),reducer:()=>{},initialState:{}};exports.RenderPlugin=n,exports.RenderPluginPackage=o;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/lib/render-plugin.ts","../src/lib/manifest.ts","../src/lib/index.ts"],"sourcesContent":["import {\n BasePlugin,\n createEmitter,\n PluginRegistry,\n REFRESH_PAGES,\n Unsubscribe,\n} from '@embedpdf/core';\nimport {\n RenderCapability,\n RenderPageOptions,\n RenderPageRectOptions,\n RenderPluginConfig,\n} from './types';\n\nexport class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {\n static readonly id = 'render' as const;\n\n private readonly refreshPages$ = createEmitter<number[]>();\n\n constructor(id: string, registry: PluginRegistry) {\n super(id, registry);\n\n this.coreStore.onAction(REFRESH_PAGES, (action) => {\n this.refreshPages$.emit(action.payload);\n });\n }\n\n async initialize(_config: RenderPluginConfig): Promise<void> {}\n\n protected buildCapability(): RenderCapability {\n return {\n renderPage: this.renderPage.bind(this),\n renderPageRect: this.renderPageRect.bind(this),\n };\n }\n\n public onRefreshPages(fn: (pages: number[]) => void): Unsubscribe {\n return this.refreshPages$.on(fn);\n }\n\n private renderPage({ pageIndex, options }: RenderPageOptions) {\n const coreState = this.coreState.core;\n\n if (!coreState.document) {\n throw new Error('document does not open');\n }\n\n const page = coreState.document.pages.find((page) => page.index === pageIndex);\n if (!page) {\n throw new Error('page does not exist');\n }\n\n return this.engine.renderPage(coreState.document, page, options);\n }\n\n private renderPageRect({ pageIndex, rect, options }: RenderPageRectOptions) {\n const coreState = this.coreState.core;\n\n if (!coreState.document) {\n throw new Error('document does not open');\n }\n\n const page = coreState.document.pages.find((page) => page.index === pageIndex);\n if (!page) {\n throw new Error('page does not exist');\n }\n\n return this.engine.renderPageRect(coreState.document, page, rect, options);\n }\n}\n","import { PluginManifest } from '@embedpdf/core';\nimport { RenderPluginConfig } from './types';\n\nexport const RENDER_PLUGIN_ID = 'render';\n\nexport const manifest: PluginManifest<RenderPluginConfig> = {\n id: RENDER_PLUGIN_ID,\n name: 'Render Plugin',\n version: '1.0.0',\n provides: ['render'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { RenderPluginConfig } from './types';\nimport { RenderPlugin } from './render-plugin';\nimport { manifest, RENDER_PLUGIN_ID } from './manifest';\n\nexport const RenderPluginPackage: PluginPackage<RenderPlugin, RenderPluginConfig> = {\n manifest,\n create: (registry) => new RenderPlugin(RENDER_PLUGIN_ID, registry),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './render-plugin';\nexport * from './types';\n"],"names":["_RenderPlugin","BasePlugin","constructor","id","registry","super","this","refreshPages$","createEmitter","coreStore","onAction","REFRESH_PAGES","action","emit","payload","initialize","_config","buildCapability","renderPage","bind","renderPageRect","onRefreshPages","fn","on","pageIndex","options","coreState","core","document","Error","page","pages","find","index","engine","rect","RenderPlugin","RENDER_PLUGIN_ID","RenderPluginPackage","manifest","name","version","provides","requires","optional","defaultConfig","enabled","create","reducer","initialState"],"mappings":"kHAcaA,EAAN,cAA2BC,EAAAA,WAKhC,WAA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ACzD4C,QAAS,OACTC,aAAc,CAAA"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/lib/render-plugin.ts","../src/lib/manifest.ts","../src/lib/index.ts"],"sourcesContent":["import {\n BasePlugin,\n createEmitter,\n PluginRegistry,\n REFRESH_PAGES,\n Unsubscribe,\n} from '@embedpdf/core';\nimport {\n RenderCapability,\n RenderPageOptions,\n RenderPageRectOptions,\n RenderPluginConfig,\n} from './types';\n\nexport class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {\n static readonly id = 'render' as const;\n\n private readonly refreshPages$ = createEmitter<number[]>();\n private withForms = false;\n private withAnnotations = false;\n\n constructor(id: string, registry: PluginRegistry) {\n super(id, registry);\n\n this.coreStore.onAction(REFRESH_PAGES, (action) => {\n this.refreshPages$.emit(action.payload);\n });\n }\n\n async initialize(config: RenderPluginConfig): Promise<void> {\n this.withForms = config.withForms ?? false;\n this.withAnnotations = config.withAnnotations ?? false;\n }\n\n protected buildCapability(): RenderCapability {\n return {\n renderPage: this.renderPage.bind(this),\n renderPageRect: this.renderPageRect.bind(this),\n };\n }\n\n public onRefreshPages(fn: (pages: number[]) => void): Unsubscribe {\n return this.refreshPages$.on(fn);\n }\n\n private renderPage({ pageIndex, options }: RenderPageOptions) {\n const coreState = this.coreState.core;\n\n if (!coreState.document) {\n throw new Error('document does not open');\n }\n\n const page = coreState.document.pages.find((page) => page.index === pageIndex);\n if (!page) {\n throw new Error('page does not exist');\n }\n\n const mergedOptions = {\n ...(options ?? {}),\n withForms: options?.withForms ?? this.withForms,\n withAnnotations: options?.withAnnotations ?? this.withAnnotations,\n };\n\n return this.engine.renderPage(coreState.document, page, mergedOptions);\n }\n\n private renderPageRect({ pageIndex, rect, options }: RenderPageRectOptions) {\n const coreState = this.coreState.core;\n\n if (!coreState.document) {\n throw new Error('document does not open');\n }\n\n const page = coreState.document.pages.find((page) => page.index === pageIndex);\n if (!page) {\n throw new Error('page does not exist');\n }\n\n const mergedOptions = {\n ...(options ?? {}),\n withForms: options?.withForms ?? this.withForms,\n withAnnotations: options?.withAnnotations ?? this.withAnnotations,\n };\n\n return this.engine.renderPageRect(coreState.document, page, rect, mergedOptions);\n }\n}\n","import { PluginManifest } from '@embedpdf/core';\nimport { RenderPluginConfig } from './types';\n\nexport const RENDER_PLUGIN_ID = 'render';\n\nexport const manifest: PluginManifest<RenderPluginConfig> = {\n id: RENDER_PLUGIN_ID,\n name: 'Render Plugin',\n version: '1.0.0',\n provides: ['render'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { RenderPluginConfig } from './types';\nimport { RenderPlugin } from './render-plugin';\nimport { manifest, RENDER_PLUGIN_ID } from './manifest';\n\nexport const RenderPluginPackage: PluginPackage<RenderPlugin, RenderPluginConfig> = {\n manifest,\n create: (registry) => new RenderPlugin(RENDER_PLUGIN_ID, registry),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './render-plugin';\nexport * from './types';\n"],"names":["_RenderPlugin","BasePlugin","constructor","id","registry","super","this","refreshPages$","createEmitter","withForms","withAnnotations","coreStore","onAction","REFRESH_PAGES","action","emit","payload","initialize","config","buildCapability","renderPage","bind","renderPageRect","onRefreshPages","fn","on","pageIndex","options","coreState","core","document","Error","page","pages","find","index","mergedOptions","engine","rect","RenderPlugin","RENDER_PLUGIN_ID","RenderPluginPackage","manifest","name","version","provides","requires","optional","defaultConfig","enabled","create","reducer","initialState"],"mappings":"kHAcaA,EAAN,cAA2BC,EAAAA,WAOhC,WAAAC,CAAYC,EAAYC,GACtBC,MAAMF,EAAIC,GALKE,KAAAC,cAAgBC,kBACjCF,KAAQG,WAAY,EACpBH,KAAQI,iBAAkB,EAKxBJ,KAAKK,UAAUC,SAASC,EAAeA,eAACC,IACjCR,KAAAC,cAAcQ,KAAKD,EAAOE,QAAO,GACvC,CAGH,gBAAMC,CAAWC,GACVZ,KAAAG,UAAYS,EAAOT,YAAa,EAChCH,KAAAI,gBAAkBQ,EA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C,SDD0D,CAC1DvC,GAAIqC,EACJG,KAAM,gBACNC,QAAS,QACTC,SAAU,CAAC,UACXC,SAAU,GACVC,SAAU,GACVC,cAAe,CACbC,SAAS,ICNXC,OAAS9C,GAAa,IAAImC,EAAaC,EAAkBpC,GACzD+C,QAAS,OACTC,aAAc,CAAA"}
package/dist/index.js CHANGED
@@ -3,11 +3,15 @@ const _RenderPlugin = class _RenderPlugin extends BasePlugin {
3
3
  constructor(id, registry) {
4
4
  super(id, registry);
5
5
  this.refreshPages$ = createEmitter();
6
+ this.withForms = false;
7
+ this.withAnnotations = false;
6
8
  this.coreStore.onAction(REFRESH_PAGES, (action) => {
7
9
  this.refreshPages$.emit(action.payload);
8
10
  });
9
11
  }
10
- async initialize(_config) {
12
+ async initialize(config) {
13
+ this.withForms = config.withForms ?? false;
14
+ this.withAnnotations = config.withAnnotations ?? false;
11
15
  }
12
16
  buildCapability() {
13
17
  return {
@@ -27,7 +31,12 @@ const _RenderPlugin = class _RenderPlugin extends BasePlugin {
27
31
  if (!page) {
28
32
  throw new Error("page does not exist");
29
33
  }
30
- return this.engine.renderPage(coreState.document, page, options);
34
+ const mergedOptions = {
35
+ ...options ?? {},
36
+ withForms: (options == null ? void 0 : options.withForms) ?? this.withForms,
37
+ withAnnotations: (options == null ? void 0 : options.withAnnotations) ?? this.withAnnotations
38
+ };
39
+ return this.engine.renderPage(coreState.document, page, mergedOptions);
31
40
  }
32
41
  renderPageRect({ pageIndex, rect, options }) {
33
42
  const coreState = this.coreState.core;
@@ -38,7 +47,12 @@ const _RenderPlugin = class _RenderPlugin extends BasePlugin {
38
47
  if (!page) {
39
48
  throw new Error("page does not exist");
40
49
  }
41
- return this.engine.renderPageRect(coreState.document, page, rect, options);
50
+ const mergedOptions = {
51
+ ...options ?? {},
52
+ withForms: (options == null ? void 0 : options.withForms) ?? this.withForms,
53
+ withAnnotations: (options == null ? void 0 : options.withAnnotations) ?? this.withAnnotations
54
+ };
55
+ return this.engine.renderPageRect(coreState.document, page, rect, mergedOptions);
42
56
  }
43
57
  };
44
58
  _RenderPlugin.id = "render";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/lib/render-plugin.ts","../src/lib/manifest.ts","../src/lib/index.ts"],"sourcesContent":["import {\n BasePlugin,\n createEmitter,\n PluginRegistry,\n REFRESH_PAGES,\n Unsubscribe,\n} from '@embedpdf/core';\nimport {\n RenderCapability,\n RenderPageOptions,\n RenderPageRectOptions,\n RenderPluginConfig,\n} from './types';\n\nexport class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {\n static readonly id = 'render' as const;\n\n private readonly refreshPages$ = createEmitter<number[]>();\n\n constructor(id: string, registry: PluginRegistry) {\n super(id, registry);\n\n this.coreStore.onAction(REFRESH_PAGES, (action) => {\n this.refreshPages$.emit(action.payload);\n });\n }\n\n async initialize(_config: RenderPluginConfig): Promise<void> {}\n\n protected buildCapability(): RenderCapability {\n return {\n renderPage: this.renderPage.bind(this),\n renderPageRect: this.renderPageRect.bind(this),\n };\n }\n\n public onRefreshPages(fn: (pages: number[]) => void): Unsubscribe {\n return this.refreshPages$.on(fn);\n }\n\n private renderPage({ pageIndex, options }: RenderPageOptions) {\n const coreState = this.coreState.core;\n\n if (!coreState.document) {\n throw new Error('document does not open');\n }\n\n const page = coreState.document.pages.find((page) => page.index === pageIndex);\n if (!page) {\n throw new Error('page does not exist');\n }\n\n return this.engine.renderPage(coreState.document, page, options);\n }\n\n private renderPageRect({ pageIndex, rect, options }: RenderPageRectOptions) {\n const coreState = this.coreState.core;\n\n if (!coreState.document) {\n throw new Error('document does not open');\n }\n\n const page = coreState.document.pages.find((page) => page.index === pageIndex);\n if (!page) {\n throw new Error('page does not exist');\n }\n\n return this.engine.renderPageRect(coreState.document, page, rect, options);\n }\n}\n","import { PluginManifest } from '@embedpdf/core';\nimport { RenderPluginConfig } from './types';\n\nexport const RENDER_PLUGIN_ID = 'render';\n\nexport const manifest: PluginManifest<RenderPluginConfig> = {\n id: RENDER_PLUGIN_ID,\n name: 'Render Plugin',\n version: '1.0.0',\n provides: ['render'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { RenderPluginConfig } from './types';\nimport { RenderPlugin } from './render-plugin';\nimport { manifest, RENDER_PLUGIN_ID } from './manifest';\n\nexport const RenderPluginPackage: PluginPackage<RenderPlugin, RenderPluginConfig> = {\n manifest,\n create: (registry) => new RenderPlugin(RENDER_PLUGIN_ID, registry),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './render-plugin';\nexport * from './types';\n"],"names":["page"],"mappings":";AAcO,MAAM,gBAAN,MAAM,sBAAqB,WAAiD;AAAA,EAKjF,YAAY,IAAY,UAA0B;AAChD,UAAM,IAAI,QAAQ;AAHpB,SAAiB,gBAAgB,cAAwB;AAKvD,SAAK,UAAU,SAAS,eAAe,CAAC,WAAW;AAC5C,WAAA,cAAc,KAAK,OAAO,OAAO;AAAA,IAAA,CACvC;AAAA,EAAA;AAAA,EAGH,MAAM,WAAW,SAA4C;AAAA,EAAA;AAAA,EAEnD,kBAAoC;AACrC,WAAA;AAAA,MACL,YAAY,KAAK,WAAW,KAAK,IAAI;AAAA,MACrC,gBAAgB,KAAK,eAAe,KAAK,IAAI;AAAA,IAC/C;AAAA,EAAA;AAAA,EAGK,eAAe,IAA4C;AACzD,WAAA,KAAK,cAAc,GAAG,EAAE;AAAA,EAAA;AAAA,EAGzB,WAAW,EAAE,WAAW,WAA8B;AACtD,UAAA,YAAY,KAAK,UAAU;AAE7B,QAAA,CAAC,UAAU,UAAU;AACjB,YAAA,IAAI,MAAM,wBAAwB;AAAA,IAAA;AAGpC,UAAA,OAAO,UAAU,SAAS,MAAM,KAAK,CAACA,UAASA,MAAK,UAAU,SAAS;AAC7E,QAAI,CAAC,MAAM;AACH,YAAA,IAAI,MAAM,qBAAqB;AAAA,IAAA;AAGvC,WAAO,KAAK,OAAO,WAAW,UAAU,UAAU,MAAM,OAAO;AAAA,EAAA;AAAA,EAGzD,eAAe,EAAE,WAAW,MAAM,WAAkC;AACpE,UAAA,YAAY,KAAK,UAAU;AAE7B,QAAA,CAAC,UAAU,UAAU;AACjB,YAAA,IAAI,MAAM,wBAAwB;AAAA,IAAA;AAGpC,UAAA,OAAO,UAAU,SAAS,MAAM,KAAK,CAACA,UAASA,MAAK,UAAU,SAAS;AAC7E,QAAI,CAAC,MAAM;AACH,YAAA,IAAI,MAAM,qBAAqB;AAAA,IAAA;AAGvC,WAAO,KAAK,OAAO,eAAe,UAAU,UAAU,MAAM,MAAM,OAAO;AAAA,EAAA;AAE7E;AAtDE,cAAgB,KAAK;AADhB,IAAM,eAAN;ACXA,MAAM,mBAAmB;AAEzB,MAAM,WAA+C;AAAA,EAC1D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,QAAQ;AAAA,EACnB,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,eAAe;AAAA,IACb,SAAS;AAAA,EAAA;AAEb;ACVO,MAAM,sBAAuE;AAAA,EAClF;AAAA,EACA,QAAQ,CAAC,aAAa,IAAI,aAAa,kBAAkB,QAAQ;AAAA,EACjE,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,cAAc,CAAA;AAChB;"}
1
+ {"version":3,"file":"index.js","sources":["../src/lib/render-plugin.ts","../src/lib/manifest.ts","../src/lib/index.ts"],"sourcesContent":["import {\n BasePlugin,\n createEmitter,\n PluginRegistry,\n REFRESH_PAGES,\n Unsubscribe,\n} from '@embedpdf/core';\nimport {\n RenderCapability,\n RenderPageOptions,\n RenderPageRectOptions,\n RenderPluginConfig,\n} from './types';\n\nexport class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {\n static readonly id = 'render' as const;\n\n private readonly refreshPages$ = createEmitter<number[]>();\n private withForms = false;\n private withAnnotations = false;\n\n constructor(id: string, registry: PluginRegistry) {\n super(id, registry);\n\n this.coreStore.onAction(REFRESH_PAGES, (action) => {\n this.refreshPages$.emit(action.payload);\n });\n }\n\n async initialize(config: RenderPluginConfig): Promise<void> {\n this.withForms = config.withForms ?? false;\n this.withAnnotations = config.withAnnotations ?? false;\n }\n\n protected buildCapability(): RenderCapability {\n return {\n renderPage: this.renderPage.bind(this),\n renderPageRect: this.renderPageRect.bind(this),\n };\n }\n\n public onRefreshPages(fn: (pages: number[]) => void): Unsubscribe {\n return this.refreshPages$.on(fn);\n }\n\n private renderPage({ pageIndex, options }: RenderPageOptions) {\n const coreState = this.coreState.core;\n\n if (!coreState.document) {\n throw new Error('document does not open');\n }\n\n const page = coreState.document.pages.find((page) => page.index === pageIndex);\n if (!page) {\n throw new Error('page does not exist');\n }\n\n const mergedOptions = {\n ...(options ?? {}),\n withForms: options?.withForms ?? this.withForms,\n withAnnotations: options?.withAnnotations ?? this.withAnnotations,\n };\n\n return this.engine.renderPage(coreState.document, page, mergedOptions);\n }\n\n private renderPageRect({ pageIndex, rect, options }: RenderPageRectOptions) {\n const coreState = this.coreState.core;\n\n if (!coreState.document) {\n throw new Error('document does not open');\n }\n\n const page = coreState.document.pages.find((page) => page.index === pageIndex);\n if (!page) {\n throw new Error('page does not exist');\n }\n\n const mergedOptions = {\n ...(options ?? {}),\n withForms: options?.withForms ?? this.withForms,\n withAnnotations: options?.withAnnotations ?? this.withAnnotations,\n };\n\n return this.engine.renderPageRect(coreState.document, page, rect, mergedOptions);\n }\n}\n","import { PluginManifest } from '@embedpdf/core';\nimport { RenderPluginConfig } from './types';\n\nexport const RENDER_PLUGIN_ID = 'render';\n\nexport const manifest: PluginManifest<RenderPluginConfig> = {\n id: RENDER_PLUGIN_ID,\n name: 'Render Plugin',\n version: '1.0.0',\n provides: ['render'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { RenderPluginConfig } from './types';\nimport { RenderPlugin } from './render-plugin';\nimport { manifest, RENDER_PLUGIN_ID } from './manifest';\n\nexport const RenderPluginPackage: PluginPackage<RenderPlugin, RenderPluginConfig> = {\n manifest,\n create: (registry) => new RenderPlugin(RENDER_PLUGIN_ID, registry),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './render-plugin';\nexport * from './types';\n"],"names":["page"],"mappings":";AAcO,MAAM,gBAAN,MAAM,sBAAqB,WAAiD;AAAA,EAOjF,YAAY,IAAY,UAA0B;AAChD,UAAM,IAAI,QAAQ;AALpB,SAAiB,gBAAgB,cAAwB;AACzD,SAAQ,YAAY;AACpB,SAAQ,kBAAkB;AAKxB,SAAK,UAAU,SAAS,eAAe,CAAC,WAAW;AAC5C,WAAA,cAAc,KAAK,OAAO,OAAO;AAAA,IAAA,CACvC;AAAA,EAAA;AAAA,EAGH,MAAM,WAAW,QAA2C;AACrD,SAAA,YAAY,OAAO,aAAa;AAChC,SAAA,kBAAkB,OAAO,mBAAmB;AAAA,EAAA;AAAA,EAGzC,kBAAoC;AACrC,WAAA;AAAA,MACL,YAAY,KAAK,WAAW,KAAK,IAAI;AAAA,MACrC,gBAAgB,KAAK,eAAe,KAAK,IAAI;AAAA,IAC/C;AAAA,EAAA;AAAA,EAGK,eAAe,IAA4C;AACzD,WAAA,KAAK,cAAc,GAAG,EAAE;AAAA,EAAA;AAAA,EAGzB,WAAW,EAAE,WAAW,WAA8B;AACtD,UAAA,YAAY,KAAK,UAAU;AAE7B,QAAA,CAAC,UAAU,UAAU;AACjB,YAAA,IAAI,MAAM,wBAAwB;AAAA,IAAA;AAGpC,UAAA,OAAO,UAAU,SAAS,MAAM,KAAK,CAACA,UAASA,MAAK,UAAU,SAAS;AAC7E,QAAI,CAAC,MAAM;AACH,YAAA,IAAI,MAAM,qBAAqB;AAAA,IAAA;AAGvC,UAAM,gBAAgB;AAAA,MACpB,GAAI,WAAW,CAAC;AAAA,MAChB,YAAW,mCAAS,cAAa,KAAK;AAAA,MACtC,kBAAiB,mCAAS,oBAAmB,KAAK;AAAA,IACpD;AAEA,WAAO,KAAK,OAAO,WAAW,UAAU,UAAU,MAAM,aAAa;AAAA,EAAA;AAAA,EAG/D,eAAe,EAAE,WAAW,MAAM,WAAkC;AACpE,UAAA,YAAY,KAAK,UAAU;AAE7B,QAAA,CAAC,UAAU,UAAU;AACjB,YAAA,IAAI,MAAM,wBAAwB;AAAA,IAAA;AAGpC,UAAA,OAAO,UAAU,SAAS,MAAM,KAAK,CAACA,UAASA,MAAK,UAAU,SAAS;AAC7E,QAAI,CAAC,MAAM;AACH,YAAA,IAAI,MAAM,qBAAqB;AAAA,IAAA;AAGvC,UAAM,gBAAgB;AAAA,MACpB,GAAI,WAAW,CAAC;AAAA,MAChB,YAAW,mCAAS,cAAa,KAAK;AAAA,MACtC,kBAAiB,mCAAS,oBAAmB,KAAK;AAAA,IACpD;AAEA,WAAO,KAAK,OAAO,eAAe,UAAU,UAAU,MAAM,MAAM,aAAa;AAAA,EAAA;AAEnF;AAvEE,cAAgB,KAAK;AADhB,IAAM,eAAN;ACXA,MAAM,mBAAmB;AAEzB,MAAM,WAA+C;AAAA,EAC1D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,QAAQ;AAAA,EACnB,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,eAAe;AAAA,IACb,SAAS;AAAA,EAAA;AAEb;ACVO,MAAM,sBAAuE;AAAA,EAClF;AAAA,EACA,QAAQ,CAAC,aAAa,IAAI,aAAa,kBAAkB,QAAQ;AAAA,EACjE,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,cAAc,CAAA;AAChB;"}
@@ -3,8 +3,10 @@ import { RenderCapability, RenderPluginConfig } from './types';
3
3
  export declare class RenderPlugin extends BasePlugin<RenderPluginConfig, RenderCapability> {
4
4
  static readonly id: "render";
5
5
  private readonly refreshPages$;
6
+ private withForms;
7
+ private withAnnotations;
6
8
  constructor(id: string, registry: PluginRegistry);
7
- initialize(_config: RenderPluginConfig): Promise<void>;
9
+ initialize(config: RenderPluginConfig): Promise<void>;
8
10
  protected buildCapability(): RenderCapability;
9
11
  onRefreshPages(fn: (pages: number[]) => void): Unsubscribe;
10
12
  private renderPage;
@@ -1,6 +1,16 @@
1
1
  import { BasePluginConfig } from '@embedpdf/core';
2
2
  import { PdfErrorReason, PdfRenderPageOptions, Rect, Task } from '@embedpdf/models';
3
3
  export interface RenderPluginConfig extends BasePluginConfig {
4
+ /**
5
+ * Initialize and draw form widgets during renders.
6
+ * Defaults to `false`.
7
+ */
8
+ withForms?: boolean;
9
+ /**
10
+ * Whether to render annotations
11
+ * Defaults to `false`.
12
+ */
13
+ withAnnotations?: boolean;
4
14
  }
5
15
  export interface RenderPageRectOptions {
6
16
  pageIndex: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-render",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.cjs",
@@ -35,13 +35,13 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@embedpdf/models": "1.4.1"
38
+ "@embedpdf/models": "1.5.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/react": "^18.2.0",
42
42
  "typescript": "^5.0.0",
43
- "@embedpdf/build": "1.1.0",
44
- "@embedpdf/core": "1.4.1"
43
+ "@embedpdf/core": "1.5.0",
44
+ "@embedpdf/build": "1.1.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "preact": "^10.26.4",
@@ -49,7 +49,7 @@
49
49
  "react-dom": ">=16.8.0",
50
50
  "vue": ">=3.2.0",
51
51
  "svelte": ">=5 <6",
52
- "@embedpdf/core": "1.4.1"
52
+ "@embedpdf/core": "1.5.0"
53
53
  },
54
54
  "files": [
55
55
  "dist",