@chialab/pdfjs-lib 1.0.0-alpha.47 → 1.0.0-alpha.48

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.
@@ -29355,17 +29355,22 @@ var renderTextLayer = (root, options = {}) => {
29355
29355
  return contents;
29356
29356
  }
29357
29357
  const tag2 = isHeading ? "span" : node.fontWeight >= 700 ? "strong" : node.fontStyle === "italic" ? "em" : "span";
29358
- const serializedAttrs2 = serializeAttributes(
29359
- classes ? {
29360
- class: "tl-text"
29361
- } : {}
29362
- );
29358
+ const attrs2 = {};
29359
+ if (classes) {
29360
+ attrs2.class = "tl-text";
29361
+ }
29362
+ if (node.colorSpace) {
29363
+ attrs2["data-color-space-type"] = node.colorSpace.type;
29364
+ attrs2["data-color-space-name"] = node.colorSpace.name;
29365
+ }
29366
+ const serializedAttrs2 = serializeAttributes(attrs2);
29363
29367
  const serializedStyle = styles ? serializeStyles({
29364
29368
  "--tl-left": `${node.left}px`,
29365
29369
  "--tl-top": `${node.top}px`,
29366
29370
  "--tl-font-size": `${node.fontSize}px`,
29367
29371
  "--tl-font-style": node.fontStyle,
29368
29372
  "--tl-font-weight": node.fontWeight,
29373
+ "--tl-font-color": node.color,
29369
29374
  "--tl-transform": typeof node.angle === "number" && node.angle !== 0 ? `rotate(${node.angle}deg)` : "none"
29370
29375
  }) : "";
29371
29376
  return `<${tag2}${serializedAttrs2 ? ` ${serializedAttrs2}` : ""}${serializedStyle ? ` style="${serializedStyle}"` : ""}>${contents}</${tag2}>`;
@@ -29716,6 +29721,8 @@ async function createTextLayer(page, {
29716
29721
  let leading = 0;
29717
29722
  let textRise = 0;
29718
29723
  let textPosition = 0;
29724
+ let fillColor;
29725
+ let fillColorSpace;
29719
29726
  const createTextItem = (fontFamily2) => {
29720
29727
  const font = page.commonObjs.get(fontFamily2);
29721
29728
  const riseMatrix = [1, 0, 0, 1, 0, textRise];
@@ -29831,7 +29838,9 @@ async function createTextLayer(page, {
29831
29838
  fontSize: fontSize2,
29832
29839
  fontWeight: font?.black ? 900 : font?.bold ? 700 : 400,
29833
29840
  fontStyle: font?.italic ? "italic" : "normal",
29834
- angle: angle * (180 / Math.PI)
29841
+ angle: angle * (180 / Math.PI),
29842
+ color: fillColor,
29843
+ colorSpace: fillColorSpace
29835
29844
  };
29836
29845
  markedContent.children.push(lastTextLayer);
29837
29846
  resetTextItem();
@@ -30096,6 +30105,8 @@ async function createTextLayer(page, {
30096
30105
  hScale = state.hScale;
30097
30106
  leading = state.leading;
30098
30107
  textRise = state.textRise;
30108
+ fillColor = state.fillColor;
30109
+ fillColorSpace = state.fillColorSpace;
30099
30110
  }
30100
30111
  break;
30101
30112
  }
@@ -30110,8 +30121,16 @@ async function createTextLayer(page, {
30110
30121
  wordSpacing,
30111
30122
  hScale,
30112
30123
  leading,
30113
- textRise
30124
+ textRise,
30125
+ fillColor,
30126
+ fillColorSpace
30114
30127
  });
30128
+ break;
30129
+ }
30130
+ case OPS.setFillRGBColor: {
30131
+ fillColor = args[0];
30132
+ fillColorSpace = args[1] ?? void 0;
30133
+ break;
30115
30134
  }
30116
30135
  }
30117
30136
  }
@@ -1,6 +1,7 @@
1
1
  import type { Font } from '../pdf.js/src/core/fonts';
2
2
  import type { PDFPageProxy, StructTreeContent } from '../pdf.js/src/display/api';
3
3
  import { type AnnotationData } from './AnnotationData';
4
+ import type { ColorSpaceInfo } from './ColorSpace';
4
5
  import type { StructTreeNodeWithAttrs } from './StructTreePage';
5
6
  import { type SvgRoot } from './Svg';
6
7
  export interface TextLayerNode {
@@ -39,6 +40,8 @@ export interface TextLayerText extends TextLayerNode {
39
40
  fontFallback: string;
40
41
  scale?: number;
41
42
  angle?: number;
43
+ color?: string;
44
+ colorSpace?: ColorSpaceInfo;
42
45
  }
43
46
  export interface TextLayerFigure extends TextLayerNode {
44
47
  role: 'figure';
@@ -27956,17 +27956,22 @@ var renderTextLayer = (root, options = {}) => {
27956
27956
  return contents;
27957
27957
  }
27958
27958
  const tag2 = isHeading ? "span" : node.fontWeight >= 700 ? "strong" : node.fontStyle === "italic" ? "em" : "span";
27959
- const serializedAttrs2 = serializeAttributes(
27960
- classes ? {
27961
- class: "tl-text"
27962
- } : {}
27963
- );
27959
+ const attrs2 = {};
27960
+ if (classes) {
27961
+ attrs2.class = "tl-text";
27962
+ }
27963
+ if (node.colorSpace) {
27964
+ attrs2["data-color-space-type"] = node.colorSpace.type;
27965
+ attrs2["data-color-space-name"] = node.colorSpace.name;
27966
+ }
27967
+ const serializedAttrs2 = serializeAttributes(attrs2);
27964
27968
  const serializedStyle = styles ? serializeStyles({
27965
27969
  "--tl-left": `${node.left}px`,
27966
27970
  "--tl-top": `${node.top}px`,
27967
27971
  "--tl-font-size": `${node.fontSize}px`,
27968
27972
  "--tl-font-style": node.fontStyle,
27969
27973
  "--tl-font-weight": node.fontWeight,
27974
+ "--tl-font-color": node.color,
27970
27975
  "--tl-transform": typeof node.angle === "number" && node.angle !== 0 ? `rotate(${node.angle}deg)` : "none"
27971
27976
  }) : "";
27972
27977
  return `<${tag2}${serializedAttrs2 ? ` ${serializedAttrs2}` : ""}${serializedStyle ? ` style="${serializedStyle}"` : ""}>${contents}</${tag2}>`;
@@ -28317,6 +28322,8 @@ async function createTextLayer(page, {
28317
28322
  let leading = 0;
28318
28323
  let textRise = 0;
28319
28324
  let textPosition = 0;
28325
+ let fillColor;
28326
+ let fillColorSpace;
28320
28327
  const createTextItem = (fontFamily2) => {
28321
28328
  const font = page.commonObjs.get(fontFamily2);
28322
28329
  const riseMatrix = [1, 0, 0, 1, 0, textRise];
@@ -28432,7 +28439,9 @@ async function createTextLayer(page, {
28432
28439
  fontSize: fontSize2,
28433
28440
  fontWeight: font?.black ? 900 : font?.bold ? 700 : 400,
28434
28441
  fontStyle: font?.italic ? "italic" : "normal",
28435
- angle: angle * (180 / Math.PI)
28442
+ angle: angle * (180 / Math.PI),
28443
+ color: fillColor,
28444
+ colorSpace: fillColorSpace
28436
28445
  };
28437
28446
  markedContent.children.push(lastTextLayer);
28438
28447
  resetTextItem();
@@ -28697,6 +28706,8 @@ async function createTextLayer(page, {
28697
28706
  hScale = state.hScale;
28698
28707
  leading = state.leading;
28699
28708
  textRise = state.textRise;
28709
+ fillColor = state.fillColor;
28710
+ fillColorSpace = state.fillColorSpace;
28700
28711
  }
28701
28712
  break;
28702
28713
  }
@@ -28711,8 +28722,16 @@ async function createTextLayer(page, {
28711
28722
  wordSpacing,
28712
28723
  hScale,
28713
28724
  leading,
28714
- textRise
28725
+ textRise,
28726
+ fillColor,
28727
+ fillColorSpace
28715
28728
  });
28729
+ break;
28730
+ }
28731
+ case OPS.setFillRGBColor: {
28732
+ fillColor = args[0];
28733
+ fillColorSpace = args[1] ?? void 0;
28734
+ break;
28716
28735
  }
28717
28736
  }
28718
28737
  }
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.47",
4
+ "version": "1.0.0-alpha.48",
5
5
  "type": "module",
6
6
  "author": "Chialab <dev@chialab.it>",
7
7
  "license": "MIT",