@chialab/pdfjs-lib 1.0.0-alpha.25 → 1.0.0-alpha.27

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.
@@ -26753,6 +26753,7 @@ var SvgCanvasContext = class {
26753
26753
  __publicField(this, "_currentGroup", null);
26754
26754
  __publicField(this, "_currentElement", null);
26755
26755
  __publicField(this, "_currentMarked", null);
26756
+ __publicField(this, "_textActive", false);
26756
26757
  __publicField(this, "_transformMatrix", new DOMMatrix([1, 0, 0, 1, 0, 0]));
26757
26758
  __publicField(this, "_currentPosition", {});
26758
26759
  __publicField(this, "_parents", /* @__PURE__ */ new Map());
@@ -27093,6 +27094,9 @@ var SvgCanvasContext = class {
27093
27094
  "stroke-width": "1"
27094
27095
  }
27095
27096
  };
27097
+ if (this._textActive) {
27098
+ pathElement.attrs["is-glyph"] = true;
27099
+ }
27096
27100
  this._applyTransformation(pathElement);
27097
27101
  this._applyStyle(pathElement, "stroke");
27098
27102
  this._addNode(pathElement);
@@ -27127,6 +27131,9 @@ var SvgCanvasContext = class {
27127
27131
  "stroke-width": "0"
27128
27132
  }
27129
27133
  };
27134
+ if (this._textActive) {
27135
+ pathElement.attrs["is-glyph"] = true;
27136
+ }
27130
27137
  this._applyTransformation(pathElement);
27131
27138
  this._applyStyle(pathElement, "fill");
27132
27139
  this._addNode(pathElement);
@@ -27261,6 +27268,9 @@ var SvgCanvasContext = class {
27261
27268
  d: toCommands(path)
27262
27269
  }
27263
27270
  };
27271
+ if (this._textActive) {
27272
+ pathElement.attrs["is-glyph"] = true;
27273
+ }
27264
27274
  this._applyTransformation(pathElement);
27265
27275
  this._addNode(pathElement, clipPath);
27266
27276
  } else if (this._currentElement) {
@@ -27283,6 +27293,12 @@ var SvgCanvasContext = class {
27283
27293
  setTransform(a, b, c, d, e, f) {
27284
27294
  this._transformMatrix = new DOMMatrix([a, b, c, d, e, f]);
27285
27295
  }
27296
+ beginText() {
27297
+ this._textActive = true;
27298
+ }
27299
+ endText() {
27300
+ this._textActive = false;
27301
+ }
27286
27302
  beginMarkedContent(type, props) {
27287
27303
  if (this._currentMarked) {
27288
27304
  this._markedStack.push(this._currentMarked);
@@ -27578,6 +27594,9 @@ var SvgCanvasContext = class {
27578
27594
  }
27579
27595
  this._currentElement.attrs.d += ` ${command}`;
27580
27596
  } else {
27597
+ if (this._textActive) {
27598
+ this._currentElement.attrs["is-glyph"] = true;
27599
+ }
27581
27600
  this._currentElement.attrs.d = command;
27582
27601
  this._addNode(this._currentElement);
27583
27602
  }
@@ -27991,6 +28010,8 @@ function isRedactAnnotation(annotation) {
27991
28010
  // src/lib/CanvasGraphics.ts
27992
28011
  var {
27993
28012
  beginDrawing,
28013
+ beginText,
28014
+ endText,
27994
28015
  beginMarkedContent,
27995
28016
  beginMarkedContentProps,
27996
28017
  endMarkedContent
@@ -28001,25 +28022,39 @@ CanvasGraphics.prototype.beginDrawing = function(options) {
28001
28022
  }
28002
28023
  return beginDrawing.call(this, options);
28003
28024
  };
28004
- CanvasGraphics.prototype.beginMarkedContent = function(type) {
28005
- beginMarkedContent.call(this, this.ctx);
28025
+ CanvasGraphics.prototype.beginText = function(opIdx) {
28026
+ beginText.call(this, opIdx);
28027
+ if (this.ctx instanceof SvgCanvasContext) {
28028
+ this.ctx.beginText();
28029
+ }
28030
+ };
28031
+ CanvasGraphics.prototype.endText = function(opIdx) {
28032
+ endText.call(this, opIdx);
28033
+ if (this.ctx instanceof SvgCanvasContext) {
28034
+ this.ctx.endText();
28035
+ }
28036
+ };
28037
+ CanvasGraphics.prototype.beginMarkedContent = function(opIdx, type) {
28038
+ beginMarkedContent.call(this, opIdx, this.ctx);
28006
28039
  if (this.ctx instanceof SvgCanvasContext) {
28007
28040
  this.ctx.beginMarkedContent(type);
28008
28041
  }
28009
28042
  };
28010
- CanvasGraphics.prototype.beginMarkedContentProps = function(type, props) {
28011
- beginMarkedContentProps.call(this, type, props);
28043
+ CanvasGraphics.prototype.beginMarkedContentProps = function(opIdx, type, props) {
28044
+ beginMarkedContentProps.call(this, opIdx, type, props);
28012
28045
  if (this.ctx instanceof SvgCanvasContext) {
28013
28046
  this.ctx.beginMarkedContent(type, props);
28014
28047
  }
28015
28048
  };
28016
- CanvasGraphics.prototype.endMarkedContent = function() {
28049
+ CanvasGraphics.prototype.endMarkedContent = function(opIdx) {
28017
28050
  if (this.ctx instanceof SvgCanvasContext) {
28018
28051
  this.ctx.endMarkedContent();
28019
28052
  }
28020
- endMarkedContent.call(this);
28053
+ endMarkedContent.call(this, opIdx);
28021
28054
  };
28022
28055
  Object.assign(CanvasGraphics.prototype, {
28056
+ [OPS.beginText]: CanvasGraphics.prototype.beginText,
28057
+ [OPS.endText]: CanvasGraphics.prototype.endText,
28023
28058
  [OPS.beginMarkedContent]: CanvasGraphics.prototype.beginMarkedContent,
28024
28059
  [OPS.beginMarkedContentProps]: CanvasGraphics.prototype.beginMarkedContentProps,
28025
28060
  [OPS.endMarkedContent]: CanvasGraphics.prototype.endMarkedContent
package/dist/lib/Svg.d.ts CHANGED
@@ -35,6 +35,7 @@ export interface SvgPath extends SvgNode<{
35
35
  fill?: string;
36
36
  stroke?: string;
37
37
  'stroke-width'?: string | number;
38
+ 'is-glyph'?: boolean;
38
39
  }> {
39
40
  tag: 'path';
40
41
  }
@@ -70,6 +70,7 @@ export declare class SvgCanvasContext {
70
70
  private _currentGroup;
71
71
  private _currentElement;
72
72
  private _currentMarked;
73
+ private _textActive;
73
74
  private _transformMatrix;
74
75
  private _currentPosition;
75
76
  private _parents;
@@ -134,6 +135,8 @@ export declare class SvgCanvasContext {
134
135
  resetTransform(): void;
135
136
  getTransform(): DOMMatrix;
136
137
  setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
138
+ beginText(): void;
139
+ endText(): void;
137
140
  beginMarkedContent(type: string, props?: number | {
138
141
  id: number;
139
142
  } | null): void;
@@ -25794,6 +25794,7 @@ var SvgCanvasContext = class {
25794
25794
  __publicField(this, "_currentGroup", null);
25795
25795
  __publicField(this, "_currentElement", null);
25796
25796
  __publicField(this, "_currentMarked", null);
25797
+ __publicField(this, "_textActive", false);
25797
25798
  __publicField(this, "_transformMatrix", new DOMMatrix([1, 0, 0, 1, 0, 0]));
25798
25799
  __publicField(this, "_currentPosition", {});
25799
25800
  __publicField(this, "_parents", /* @__PURE__ */ new Map());
@@ -26134,6 +26135,9 @@ var SvgCanvasContext = class {
26134
26135
  "stroke-width": "1"
26135
26136
  }
26136
26137
  };
26138
+ if (this._textActive) {
26139
+ pathElement.attrs["is-glyph"] = true;
26140
+ }
26137
26141
  this._applyTransformation(pathElement);
26138
26142
  this._applyStyle(pathElement, "stroke");
26139
26143
  this._addNode(pathElement);
@@ -26168,6 +26172,9 @@ var SvgCanvasContext = class {
26168
26172
  "stroke-width": "0"
26169
26173
  }
26170
26174
  };
26175
+ if (this._textActive) {
26176
+ pathElement.attrs["is-glyph"] = true;
26177
+ }
26171
26178
  this._applyTransformation(pathElement);
26172
26179
  this._applyStyle(pathElement, "fill");
26173
26180
  this._addNode(pathElement);
@@ -26302,6 +26309,9 @@ var SvgCanvasContext = class {
26302
26309
  d: toCommands(path)
26303
26310
  }
26304
26311
  };
26312
+ if (this._textActive) {
26313
+ pathElement.attrs["is-glyph"] = true;
26314
+ }
26305
26315
  this._applyTransformation(pathElement);
26306
26316
  this._addNode(pathElement, clipPath);
26307
26317
  } else if (this._currentElement) {
@@ -26324,6 +26334,12 @@ var SvgCanvasContext = class {
26324
26334
  setTransform(a, b, c, d, e, f) {
26325
26335
  this._transformMatrix = new DOMMatrix([a, b, c, d, e, f]);
26326
26336
  }
26337
+ beginText() {
26338
+ this._textActive = true;
26339
+ }
26340
+ endText() {
26341
+ this._textActive = false;
26342
+ }
26327
26343
  beginMarkedContent(type, props) {
26328
26344
  if (this._currentMarked) {
26329
26345
  this._markedStack.push(this._currentMarked);
@@ -26619,6 +26635,9 @@ var SvgCanvasContext = class {
26619
26635
  }
26620
26636
  this._currentElement.attrs.d += ` ${command}`;
26621
26637
  } else {
26638
+ if (this._textActive) {
26639
+ this._currentElement.attrs["is-glyph"] = true;
26640
+ }
26622
26641
  this._currentElement.attrs.d = command;
26623
26642
  this._addNode(this._currentElement);
26624
26643
  }
@@ -27032,6 +27051,8 @@ function isRedactAnnotation(annotation) {
27032
27051
  // src/lib/CanvasGraphics.ts
27033
27052
  var {
27034
27053
  beginDrawing,
27054
+ beginText,
27055
+ endText,
27035
27056
  beginMarkedContent,
27036
27057
  beginMarkedContentProps,
27037
27058
  endMarkedContent
@@ -27042,25 +27063,39 @@ CanvasGraphics.prototype.beginDrawing = function(options) {
27042
27063
  }
27043
27064
  return beginDrawing.call(this, options);
27044
27065
  };
27045
- CanvasGraphics.prototype.beginMarkedContent = function(type) {
27046
- beginMarkedContent.call(this, this.ctx);
27066
+ CanvasGraphics.prototype.beginText = function(opIdx) {
27067
+ beginText.call(this, opIdx);
27068
+ if (this.ctx instanceof SvgCanvasContext) {
27069
+ this.ctx.beginText();
27070
+ }
27071
+ };
27072
+ CanvasGraphics.prototype.endText = function(opIdx) {
27073
+ endText.call(this, opIdx);
27074
+ if (this.ctx instanceof SvgCanvasContext) {
27075
+ this.ctx.endText();
27076
+ }
27077
+ };
27078
+ CanvasGraphics.prototype.beginMarkedContent = function(opIdx, type) {
27079
+ beginMarkedContent.call(this, opIdx, this.ctx);
27047
27080
  if (this.ctx instanceof SvgCanvasContext) {
27048
27081
  this.ctx.beginMarkedContent(type);
27049
27082
  }
27050
27083
  };
27051
- CanvasGraphics.prototype.beginMarkedContentProps = function(type, props) {
27052
- beginMarkedContentProps.call(this, type, props);
27084
+ CanvasGraphics.prototype.beginMarkedContentProps = function(opIdx, type, props) {
27085
+ beginMarkedContentProps.call(this, opIdx, type, props);
27053
27086
  if (this.ctx instanceof SvgCanvasContext) {
27054
27087
  this.ctx.beginMarkedContent(type, props);
27055
27088
  }
27056
27089
  };
27057
- CanvasGraphics.prototype.endMarkedContent = function() {
27090
+ CanvasGraphics.prototype.endMarkedContent = function(opIdx) {
27058
27091
  if (this.ctx instanceof SvgCanvasContext) {
27059
27092
  this.ctx.endMarkedContent();
27060
27093
  }
27061
- endMarkedContent.call(this);
27094
+ endMarkedContent.call(this, opIdx);
27062
27095
  };
27063
27096
  Object.assign(CanvasGraphics.prototype, {
27097
+ [OPS.beginText]: CanvasGraphics.prototype.beginText,
27098
+ [OPS.endText]: CanvasGraphics.prototype.endText,
27064
27099
  [OPS.beginMarkedContent]: CanvasGraphics.prototype.beginMarkedContent,
27065
27100
  [OPS.beginMarkedContentProps]: CanvasGraphics.prototype.beginMarkedContentProps,
27066
27101
  [OPS.endMarkedContent]: CanvasGraphics.prototype.endMarkedContent
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chialab/pdfjs-lib",
3
3
  "description": "A custom Mozilla's PDF.js build with better Node support and extras.",
4
- "version": "1.0.0-alpha.25",
4
+ "version": "1.0.0-alpha.27",
5
5
  "type": "module",
6
6
  "author": "Chialab <dev@chialab.it>",
7
7
  "license": "MIT",