mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Introduce helper functions for parsing /Matrix and /BBox arrays
This commit is contained in:
parent
52f7ff155d
commit
9b41bfc374
5 changed files with 63 additions and 69 deletions
|
@ -19,6 +19,7 @@ import {
|
|||
BaseException,
|
||||
objectSize,
|
||||
stringToPDFString,
|
||||
Util,
|
||||
warn,
|
||||
} from "../shared/util.js";
|
||||
import { Dict, isName, Ref, RefSet } from "./primitives.js";
|
||||
|
@ -248,6 +249,21 @@ function isNumberArray(arr, len) {
|
|||
);
|
||||
}
|
||||
|
||||
// Returns the matrix, or the fallback value if it's invalid.
|
||||
function lookupMatrix(arr, fallback) {
|
||||
return isNumberArray(arr, 6) ? arr : fallback;
|
||||
}
|
||||
|
||||
// Returns the rectangle, or the fallback value if it's invalid.
|
||||
function lookupRect(arr, fallback) {
|
||||
return isNumberArray(arr, 4) ? arr : fallback;
|
||||
}
|
||||
|
||||
// Returns the normalized rectangle, or the fallback value if it's invalid.
|
||||
function lookupNormalRect(arr, fallback) {
|
||||
return isNumberArray(arr, 4) ? Util.normalizeRect(arr) : fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* AcroForm field names use an array like notation to refer to
|
||||
* repeated XFA elements e.g. foo.bar[nnn].
|
||||
|
@ -671,6 +687,9 @@ export {
|
|||
isNumberArray,
|
||||
isWhiteSpace,
|
||||
log2,
|
||||
lookupMatrix,
|
||||
lookupNormalRect,
|
||||
lookupRect,
|
||||
MissingDataException,
|
||||
numberToString,
|
||||
ParserEOFException,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue