@kittl/pdfkit 0.17.5 → 0.17.51

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/js/write_svg.js CHANGED
@@ -737,6 +737,14 @@ function write_svg (doc, svg, x, y, options) {
737
737
  color: 'Color',
738
738
  luminosity: 'Luminosity'
739
739
  };
740
+ const maskBackdrop = [0, 0, 0];
741
+ if (doc._activeColorProfile) {
742
+ let i = doc._activeColorProfile.channels - 3;
743
+ while (i > 0) {
744
+ maskBackdrop.push(0);
745
+ i--;
746
+ }
747
+ }
740
748
  function docBeginGroup(bbox) {
741
749
  let group = new function PDFGroup() {}();
742
750
  group.name = 'G' + (doc._groupCount = (doc._groupCount || 0) + 1);
@@ -805,9 +813,9 @@ function write_svg (doc, svg, x, y, options) {
805
813
  ca: 1,
806
814
  BM: 'Normal',
807
815
  SMask: {
808
- S: 'Luminosity',
816
+ S: clip ? 'Alpha' : 'Luminosity',
809
817
  G: group.xobj,
810
- BC: clip ? [0, 0, 0] : [1, 1, 1]
818
+ BC: maskBackdrop
811
819
  }
812
820
  });
813
821
  gstate.end();
@@ -1131,7 +1139,7 @@ function write_svg (doc, svg, x, y, options) {
1131
1139
  let newColor = color[0].slice(),
1132
1140
  newOpacity = color[1] * opacity;
1133
1141
  if (isMask) {
1134
- for (let i = 0; i < color.length; i++) {
1142
+ for (let i = 0; i < newColor.length; i++) {
1135
1143
  newColor[i] *= newOpacity;
1136
1144
  }
1137
1145
  return [newColor, 1];
@@ -3141,7 +3149,7 @@ function write_svg (doc, svg, x, y, options) {
3141
3149
  this.drawChildren(false, true);
3142
3150
  doc.restore();
3143
3151
  docEndGroup(group);
3144
- docApplyMask(group, true);
3152
+ docApplyMask(group, false);
3145
3153
  };
3146
3154
  };
3147
3155
  var SvgElemTextContainer = function (obj, inherits) {