@box/pdfjs-dist 6.4.299-box.1 → 6.4.299-box.3
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/CHANGELOG.md +20 -0
- package/README.md +10 -0
- package/build/pdf.min.mjs +4 -4
- package/build/pdf.mjs +153 -13
- package/build/pdf.mjs.map +1 -1
- package/build/pdf.sandbox.min.mjs +2 -2
- package/build/pdf.sandbox.mjs +2 -2
- package/build/pdf.worker.min.mjs +3 -3
- package/build/pdf.worker.mjs +3 -3
- package/image_decoders/pdf.image_decoders.min.mjs +2 -2
- package/image_decoders/pdf.image_decoders.mjs +2 -2
- package/legacy/build/pdf.min.mjs +4 -4
- package/legacy/build/pdf.mjs +161 -19
- package/legacy/build/pdf.mjs.map +1 -1
- package/legacy/build/pdf.sandbox.min.mjs +2 -2
- package/legacy/build/pdf.sandbox.mjs +2 -2
- package/legacy/build/pdf.worker.min.mjs +3 -3
- package/legacy/build/pdf.worker.mjs +3 -3
- package/legacy/image_decoders/pdf.image_decoders.min.mjs +2 -2
- package/legacy/image_decoders/pdf.image_decoders.mjs +2 -2
- package/legacy/web/pdf_viewer.mjs +5 -4
- package/legacy/web/pdf_viewer.mjs.map +1 -1
- package/package.json +4 -3
- package/types/src/display/display_utils.d.ts +51 -0
- package/types/src/pdf.d.ts +2 -1
- package/web/pdf_viewer.mjs +5 -4
- package/web/pdf_viewer.mjs.map +1 -1
package/build/pdf.mjs
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* pdfjsVersion = 6.4.299-box.
|
|
24
|
-
* pdfjsBuild =
|
|
23
|
+
* pdfjsVersion = 6.4.299-box.3
|
|
24
|
+
* pdfjsBuild = acc2002
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
;// ./src/shared/util.js
|
|
@@ -1759,6 +1759,138 @@ function renderRichText({
|
|
|
1759
1759
|
fragment.firstElementChild.classList.add("richText", className);
|
|
1760
1760
|
container.append(fragment);
|
|
1761
1761
|
}
|
|
1762
|
+
let isBoxChangesSwitchOn = true;
|
|
1763
|
+
function setBoxChangesEnabled(enabled) {
|
|
1764
|
+
if (typeof enabled !== "boolean") {
|
|
1765
|
+
throw new Error("Invalid `enabled` type.");
|
|
1766
|
+
}
|
|
1767
|
+
isBoxChangesSwitchOn = enabled;
|
|
1768
|
+
}
|
|
1769
|
+
function areBoxChangesEnabled() {
|
|
1770
|
+
return isBoxChangesSwitchOn;
|
|
1771
|
+
}
|
|
1772
|
+
const axisAlignedClipPaths = new WeakMap();
|
|
1773
|
+
const NEAR_ZERO_TRANSFORM_RATIO = 1e-6;
|
|
1774
|
+
const MIN_SNAPPED_CLIP_SIZE = 2;
|
|
1775
|
+
function isNearZero(value, scale) {
|
|
1776
|
+
return Math.abs(value) <= NEAR_ZERO_TRANSFORM_RATIO * Math.abs(scale);
|
|
1777
|
+
}
|
|
1778
|
+
function isAxisAlignedScale([a, b, c, d]) {
|
|
1779
|
+
return isNearZero(b, a) && isNearZero(c, d);
|
|
1780
|
+
}
|
|
1781
|
+
function isQuarterTurn([a, b, c, d]) {
|
|
1782
|
+
return isNearZero(a, b) && isNearZero(d, c);
|
|
1783
|
+
}
|
|
1784
|
+
function isAxisAlignedEdge(x0, y0, x1, y1) {
|
|
1785
|
+
return x0 === x1 || y0 === y1;
|
|
1786
|
+
}
|
|
1787
|
+
function updateMinSubpathSize(minSubpathSize, [minX, minY, maxX, maxY]) {
|
|
1788
|
+
const hasEdges = minX !== Infinity;
|
|
1789
|
+
if (hasEdges) {
|
|
1790
|
+
minSubpathSize[0] = Math.min(minSubpathSize[0], maxX - minX);
|
|
1791
|
+
minSubpathSize[1] = Math.min(minSubpathSize[1], maxY - minY);
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
function getAxisAlignedPath(data) {
|
|
1795
|
+
const minSubpathSize = [Infinity, Infinity];
|
|
1796
|
+
let subpathMinMax = BBOX_INIT.slice();
|
|
1797
|
+
let hasSubpath = false;
|
|
1798
|
+
let startX = 0;
|
|
1799
|
+
let startY = 0;
|
|
1800
|
+
let currentX = 0;
|
|
1801
|
+
let currentY = 0;
|
|
1802
|
+
for (let i = 0, ii = data.length; i < ii;) {
|
|
1803
|
+
switch (data[i++]) {
|
|
1804
|
+
case DrawOPS.moveTo:
|
|
1805
|
+
if (!isAxisAlignedEdge(currentX, currentY, startX, startY)) {
|
|
1806
|
+
return null;
|
|
1807
|
+
}
|
|
1808
|
+
updateMinSubpathSize(minSubpathSize, subpathMinMax);
|
|
1809
|
+
subpathMinMax = BBOX_INIT.slice();
|
|
1810
|
+
hasSubpath = true;
|
|
1811
|
+
startX = currentX = data[i++];
|
|
1812
|
+
startY = currentY = data[i++];
|
|
1813
|
+
break;
|
|
1814
|
+
case DrawOPS.lineTo:
|
|
1815
|
+
{
|
|
1816
|
+
const x = data[i++];
|
|
1817
|
+
const y = data[i++];
|
|
1818
|
+
if (!hasSubpath || !isAxisAlignedEdge(currentX, currentY, x, y)) {
|
|
1819
|
+
return null;
|
|
1820
|
+
}
|
|
1821
|
+
Util.rectBoundingBox(currentX, currentY, x, y, subpathMinMax);
|
|
1822
|
+
currentX = x;
|
|
1823
|
+
currentY = y;
|
|
1824
|
+
break;
|
|
1825
|
+
}
|
|
1826
|
+
case DrawOPS.closePath:
|
|
1827
|
+
if (!isAxisAlignedEdge(currentX, currentY, startX, startY)) {
|
|
1828
|
+
return null;
|
|
1829
|
+
}
|
|
1830
|
+
updateMinSubpathSize(minSubpathSize, subpathMinMax);
|
|
1831
|
+
subpathMinMax = BBOX_INIT.slice();
|
|
1832
|
+
currentX = startX;
|
|
1833
|
+
currentY = startY;
|
|
1834
|
+
break;
|
|
1835
|
+
default:
|
|
1836
|
+
return null;
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
if (!isAxisAlignedEdge(currentX, currentY, startX, startY)) {
|
|
1840
|
+
return null;
|
|
1841
|
+
}
|
|
1842
|
+
updateMinSubpathSize(minSubpathSize, subpathMinMax);
|
|
1843
|
+
const [minSubpathWidth, minSubpathHeight] = minSubpathSize;
|
|
1844
|
+
return minSubpathWidth > 0 && minSubpathHeight > 0 && minSubpathWidth < Infinity ? {
|
|
1845
|
+
data,
|
|
1846
|
+
minSubpathWidth,
|
|
1847
|
+
minSubpathHeight
|
|
1848
|
+
} : null;
|
|
1849
|
+
}
|
|
1850
|
+
function snapToDevicePixel(coordinate, scale, offset) {
|
|
1851
|
+
return (Math.round(scale * coordinate + offset) - offset) / scale;
|
|
1852
|
+
}
|
|
1853
|
+
function snapAxisAlignedPath({
|
|
1854
|
+
data,
|
|
1855
|
+
minSubpathWidth,
|
|
1856
|
+
minSubpathHeight
|
|
1857
|
+
}, transform) {
|
|
1858
|
+
const [a, b, c, d, e, f] = transform;
|
|
1859
|
+
let scaleX, offsetX, scaleY, offsetY;
|
|
1860
|
+
if (isAxisAlignedScale(transform)) {
|
|
1861
|
+
[scaleX, offsetX, scaleY, offsetY] = [a, e, d, f];
|
|
1862
|
+
} else if (isQuarterTurn(transform)) {
|
|
1863
|
+
[scaleX, offsetX, scaleY, offsetY] = [b, f, c, e];
|
|
1864
|
+
} else {
|
|
1865
|
+
return null;
|
|
1866
|
+
}
|
|
1867
|
+
if (Math.abs(scaleX * minSubpathWidth) < MIN_SNAPPED_CLIP_SIZE || Math.abs(scaleY * minSubpathHeight) < MIN_SNAPPED_CLIP_SIZE) {
|
|
1868
|
+
return null;
|
|
1869
|
+
}
|
|
1870
|
+
const snappedDrawOPS = [];
|
|
1871
|
+
for (let i = 0, ii = data.length; i < ii;) {
|
|
1872
|
+
const op = data[i++];
|
|
1873
|
+
snappedDrawOPS.push(op);
|
|
1874
|
+
if (op === DrawOPS.moveTo || op === DrawOPS.lineTo) {
|
|
1875
|
+
snappedDrawOPS.push(snapToDevicePixel(data[i++], scaleX, offsetX), snapToDevicePixel(data[i++], scaleY, offsetY));
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
return snappedDrawOPS;
|
|
1879
|
+
}
|
|
1880
|
+
function recordClipPath(path, data) {
|
|
1881
|
+
const axisAlignedPath = getAxisAlignedPath(data);
|
|
1882
|
+
if (axisAlignedPath) {
|
|
1883
|
+
axisAlignedClipPaths.set(path, axisAlignedPath);
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
function getPixelSnappedClipPath(path, transform) {
|
|
1887
|
+
if (!areBoxChangesEnabled()) {
|
|
1888
|
+
return path;
|
|
1889
|
+
}
|
|
1890
|
+
const axisAlignedPath = axisAlignedClipPaths.get(path);
|
|
1891
|
+
const snappedDrawOPS = axisAlignedPath && snapAxisAlignedPath(axisAlignedPath, transform);
|
|
1892
|
+
return snappedDrawOPS ? makePathFromDrawOPS(snappedDrawOPS) : path;
|
|
1893
|
+
}
|
|
1762
1894
|
function makePathFromDrawOPS(data) {
|
|
1763
1895
|
const path = new Path2D();
|
|
1764
1896
|
if (!data) {
|
|
@@ -2094,7 +2226,7 @@ class FloatingToolbar {
|
|
|
2094
2226
|
}
|
|
2095
2227
|
|
|
2096
2228
|
;// ./src/shared/internal_evt.js
|
|
2097
|
-
const INTERNAL_EVT = "
|
|
2229
|
+
const INTERNAL_EVT = "1f166d3a-715c-4c7a-a062-1e0ddfefab93";
|
|
2098
2230
|
const internalOpt = Object.freeze({
|
|
2099
2231
|
internal: INTERNAL_EVT
|
|
2100
2232
|
});
|
|
@@ -10581,8 +10713,10 @@ function mirrorContextOperations(ctx, destCtx) {
|
|
|
10581
10713
|
};
|
|
10582
10714
|
}
|
|
10583
10715
|
function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, destY, destW, destH) {
|
|
10584
|
-
const
|
|
10585
|
-
|
|
10716
|
+
const transform = getCurrentTransform(ctx);
|
|
10717
|
+
const [a, b, c, d, tx, ty] = transform;
|
|
10718
|
+
const isRoundingTolerated = areBoxChangesEnabled();
|
|
10719
|
+
if (isRoundingTolerated ? isAxisAlignedScale(transform) : b === 0 && c === 0) {
|
|
10586
10720
|
const tlX = destX * a + tx;
|
|
10587
10721
|
const rTlX = Math.round(tlX);
|
|
10588
10722
|
const tlY = destY * d + ty;
|
|
@@ -10596,7 +10730,7 @@ function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, de
|
|
|
10596
10730
|
ctx.setTransform(a, b, c, d, tx, ty);
|
|
10597
10731
|
return [rWidth, rHeight];
|
|
10598
10732
|
}
|
|
10599
|
-
if (a === 0 && d === 0) {
|
|
10733
|
+
if (isRoundingTolerated ? isQuarterTurn(transform) : a === 0 && d === 0) {
|
|
10600
10734
|
const tlX = destY * c + tx;
|
|
10601
10735
|
const rTlX = Math.round(tlX);
|
|
10602
10736
|
const tlY = destX * b + ty;
|
|
@@ -11822,7 +11956,11 @@ class CanvasGraphics {
|
|
|
11822
11956
|
this.dependencyTracker.resetBBox(opIdx).recordBBox(opIdx, this.ctx, minMax[0] - outerExtraSize, minMax[2] + outerExtraSize, minMax[1] - outerExtraSize, minMax[3] + outerExtraSize).recordDependencies(opIdx, ["transform"]);
|
|
11823
11957
|
}
|
|
11824
11958
|
if (!(path instanceof Path2D)) {
|
|
11825
|
-
|
|
11959
|
+
const drawOPS = path;
|
|
11960
|
+
path = data[0] = makePathFromDrawOPS(drawOPS);
|
|
11961
|
+
if (this.pendingClip) {
|
|
11962
|
+
recordClipPath(path, drawOPS);
|
|
11963
|
+
}
|
|
11826
11964
|
}
|
|
11827
11965
|
Util.axialAlignedBoundingBox(minMax, getCurrentTransform(this.ctx), this.current.minMax);
|
|
11828
11966
|
const tilingDims = this.current.tilingPatternDims;
|
|
@@ -13152,10 +13290,11 @@ class CanvasGraphics {
|
|
|
13152
13290
|
const ctx = this.ctx;
|
|
13153
13291
|
if (this.pendingClip) {
|
|
13154
13292
|
if (!isEmpty) {
|
|
13293
|
+
const clipPath = getPixelSnappedClipPath(path, getCurrentTransform(ctx));
|
|
13155
13294
|
if (this.pendingClip === EO_CLIP) {
|
|
13156
|
-
ctx.clip(
|
|
13295
|
+
ctx.clip(clipPath, "evenodd");
|
|
13157
13296
|
} else {
|
|
13158
|
-
ctx.clip(
|
|
13297
|
+
ctx.clip(clipPath);
|
|
13159
13298
|
}
|
|
13160
13299
|
}
|
|
13161
13300
|
this.pendingClip = null;
|
|
@@ -15464,7 +15603,7 @@ function getDocument(src = {}) {
|
|
|
15464
15603
|
}
|
|
15465
15604
|
const docParams = {
|
|
15466
15605
|
docId,
|
|
15467
|
-
apiVersion: "6.4.299-box.
|
|
15606
|
+
apiVersion: "6.4.299-box.3",
|
|
15468
15607
|
data,
|
|
15469
15608
|
password,
|
|
15470
15609
|
disableAutoFetch,
|
|
@@ -17165,8 +17304,8 @@ class InternalRenderTask {
|
|
|
17165
17304
|
}
|
|
17166
17305
|
}
|
|
17167
17306
|
}
|
|
17168
|
-
const version = "6.4.299-box.
|
|
17169
|
-
const build = "
|
|
17307
|
+
const version = "6.4.299-box.3";
|
|
17308
|
+
const build = "acc2002";
|
|
17170
17309
|
|
|
17171
17310
|
;// ./src/display/editor/color_picker.js
|
|
17172
17311
|
|
|
@@ -28191,6 +28330,7 @@ globalThis.pdfjsLib = {
|
|
|
28191
28330
|
RenderingCancelledException: RenderingCancelledException,
|
|
28192
28331
|
renderRichText: renderRichText,
|
|
28193
28332
|
ResponseException: ResponseException,
|
|
28333
|
+
setBoxChangesEnabled: setBoxChangesEnabled,
|
|
28194
28334
|
setLayerDimensions: setLayerDimensions,
|
|
28195
28335
|
shadow: shadow,
|
|
28196
28336
|
SignatureExtractor: SignatureExtractor,
|
|
@@ -28206,6 +28346,6 @@ globalThis.pdfjsLib = {
|
|
|
28206
28346
|
XfaLayer: XfaLayer
|
|
28207
28347
|
};
|
|
28208
28348
|
|
|
28209
|
-
export { AbortException, AnnotationEditorLayer, AnnotationEditorParamsType, AnnotationEditorType, AnnotationEditorUIManager, AnnotationLayer, AnnotationMode, AnnotationType, CSSConstants, ColorPicker, DOMSVGFactory, DrawLayer, FeatureTest, GlobalWorkerOptions, ImageKind, InvalidPDFException, MathClamp, OPS, OutputScale, PDFDataRangeTransport, PDFDateString, PDFWorker, PasswordException, PasswordResponses, PermissionFlag, PixelsPerInch, RenderingCancelledException, ResponseException, SignatureExtractor, SupportedImageMimeTypes, TextLayer, TextLayerImages, TouchManager, Util, VerbosityLevel, XfaLayer, applyOpacity, build, createValidAbsoluteUrl, fetchData, findContrastColor, getDocument, getFilenameFromUrl, getPdfFilenameFromUrl, getRGB, getRGBA, getUuid, isDataScheme, isPdfFile, isValidExplicitDest, makeArr, makeMap, makeObj, makeSet, noContextMenu, normalizeUnicode, renderRichText, setLayerDimensions, shadow, stopEvent, updateUrlHash, version };
|
|
28349
|
+
export { AbortException, AnnotationEditorLayer, AnnotationEditorParamsType, AnnotationEditorType, AnnotationEditorUIManager, AnnotationLayer, AnnotationMode, AnnotationType, CSSConstants, ColorPicker, DOMSVGFactory, DrawLayer, FeatureTest, GlobalWorkerOptions, ImageKind, InvalidPDFException, MathClamp, OPS, OutputScale, PDFDataRangeTransport, PDFDateString, PDFWorker, PasswordException, PasswordResponses, PermissionFlag, PixelsPerInch, RenderingCancelledException, ResponseException, SignatureExtractor, SupportedImageMimeTypes, TextLayer, TextLayerImages, TouchManager, Util, VerbosityLevel, XfaLayer, applyOpacity, build, createValidAbsoluteUrl, fetchData, findContrastColor, getDocument, getFilenameFromUrl, getPdfFilenameFromUrl, getRGB, getRGBA, getUuid, isDataScheme, isPdfFile, isValidExplicitDest, makeArr, makeMap, makeObj, makeSet, noContextMenu, normalizeUnicode, renderRichText, setBoxChangesEnabled, setLayerDimensions, shadow, stopEvent, updateUrlHash, version };
|
|
28210
28350
|
|
|
28211
28351
|
//# sourceMappingURL=pdf.mjs.map
|