mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Move worker-thread only functions from src/shared/util.js
and into a new src/core/core_utils.js
file
The `src/shared/util.js` file is being bundled into both the `pdf.js` and `pdf.worker.js` files, meaning that its code is by definition duplicated. Some main-thread only utility functions have already been moved to a separate `src/display/display_utils.js` file, and this patch simply extends that concept to utility functions which are used *only* on the worker-thread. Note in particular the `getInheritableProperty` function, which expects a `Dict` as input and thus *cannot* possibly ever be used on the main-thread.
This commit is contained in:
parent
a1f7517996
commit
db5dc14158
21 changed files with 359 additions and 308 deletions
|
@ -16,12 +16,12 @@
|
|||
|
||||
import {
|
||||
AnnotationBorderStyleType, AnnotationFieldFlag, AnnotationFlag,
|
||||
AnnotationType, getInheritableProperty, OPS, stringToBytes, stringToPDFString,
|
||||
Util, warn
|
||||
AnnotationType, OPS, stringToBytes, stringToPDFString, Util, warn
|
||||
} from '../shared/util';
|
||||
import { Catalog, FileSpec, ObjectLoader } from './obj';
|
||||
import { Dict, isDict, isName, isRef, isStream } from './primitives';
|
||||
import { ColorSpace } from './colorspace';
|
||||
import { getInheritableProperty } from './core_utils';
|
||||
import { OperatorList } from './operator_list';
|
||||
import { Stream } from './stream';
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
/* eslint no-var: error */
|
||||
|
||||
import {
|
||||
arrayByteLength, arraysToBytes, createPromiseCapability, isEmptyObj,
|
||||
MissingDataException
|
||||
arrayByteLength, arraysToBytes, createPromiseCapability, isEmptyObj
|
||||
} from '../shared/util';
|
||||
import { MissingDataException } from './core_utils';
|
||||
|
||||
class ChunkedStream {
|
||||
constructor(length, chunkSize, manager) {
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
CMapCompressionType, FormatError, isString, MissingDataException, unreachable,
|
||||
warn
|
||||
CMapCompressionType, FormatError, isString, unreachable, warn
|
||||
} from '../shared/util';
|
||||
import { isCmd, isEOF, isName, isStream } from './primitives';
|
||||
import { Lexer } from './parser';
|
||||
import { MissingDataException } from './core_utils';
|
||||
import { Stream } from './stream';
|
||||
|
||||
var BUILT_IN_CMAPS = [
|
||||
|
|
160
src/core/core_utils.js
Normal file
160
src/core/core_utils.js
Normal file
|
@ -0,0 +1,160 @@
|
|||
/* Copyright 2019 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* eslint no-var: error */
|
||||
|
||||
import { assert, warn } from '../shared/util';
|
||||
|
||||
function getLookupTableFactory(initializer) {
|
||||
let lookup;
|
||||
return function() {
|
||||
if (initializer) {
|
||||
lookup = Object.create(null);
|
||||
initializer(lookup);
|
||||
initializer = null;
|
||||
}
|
||||
return lookup;
|
||||
};
|
||||
}
|
||||
|
||||
const MissingDataException = (function MissingDataExceptionClosure() {
|
||||
function MissingDataException(begin, end) {
|
||||
this.begin = begin;
|
||||
this.end = end;
|
||||
this.message = `Missing data [${begin}, ${end})`;
|
||||
}
|
||||
|
||||
MissingDataException.prototype = new Error();
|
||||
MissingDataException.prototype.name = 'MissingDataException';
|
||||
MissingDataException.constructor = MissingDataException;
|
||||
|
||||
return MissingDataException;
|
||||
})();
|
||||
|
||||
const XRefEntryException = (function XRefEntryExceptionClosure() {
|
||||
function XRefEntryException(msg) {
|
||||
this.message = msg;
|
||||
}
|
||||
|
||||
XRefEntryException.prototype = new Error();
|
||||
XRefEntryException.prototype.name = 'XRefEntryException';
|
||||
XRefEntryException.constructor = XRefEntryException;
|
||||
|
||||
return XRefEntryException;
|
||||
})();
|
||||
|
||||
const XRefParseException = (function XRefParseExceptionClosure() {
|
||||
function XRefParseException(msg) {
|
||||
this.message = msg;
|
||||
}
|
||||
|
||||
XRefParseException.prototype = new Error();
|
||||
XRefParseException.prototype.name = 'XRefParseException';
|
||||
XRefParseException.constructor = XRefParseException;
|
||||
|
||||
return XRefParseException;
|
||||
})();
|
||||
|
||||
/**
|
||||
* Get the value of an inheritable property.
|
||||
*
|
||||
* If the PDF specification explicitly lists a property in a dictionary as
|
||||
* inheritable, then the value of the property may be present in the dictionary
|
||||
* itself or in one or more parents of the dictionary.
|
||||
*
|
||||
* If the key is not found in the tree, `undefined` is returned. Otherwise,
|
||||
* the value for the key is returned or, if `stopWhenFound` is `false`, a list
|
||||
* of values is returned. To avoid infinite loops, the traversal is stopped when
|
||||
* the loop limit is reached.
|
||||
*
|
||||
* @param {Dict} dict - Dictionary from where to start the traversal.
|
||||
* @param {string} key - The key of the property to find the value for.
|
||||
* @param {boolean} getArray - Whether or not the value should be fetched as an
|
||||
* array. The default value is `false`.
|
||||
* @param {boolean} stopWhenFound - Whether or not to stop the traversal when
|
||||
* the key is found. If set to `false`, we always walk up the entire parent
|
||||
* chain, for example to be able to find `\Resources` placed on multiple
|
||||
* levels of the tree. The default value is `true`.
|
||||
*/
|
||||
function getInheritableProperty({ dict, key, getArray = false,
|
||||
stopWhenFound = true, }) {
|
||||
const LOOP_LIMIT = 100;
|
||||
let loopCount = 0;
|
||||
let values;
|
||||
|
||||
while (dict) {
|
||||
const value = getArray ? dict.getArray(key) : dict.get(key);
|
||||
if (value !== undefined) {
|
||||
if (stopWhenFound) {
|
||||
return value;
|
||||
}
|
||||
if (!values) {
|
||||
values = [];
|
||||
}
|
||||
values.push(value);
|
||||
}
|
||||
if (++loopCount > LOOP_LIMIT) {
|
||||
warn(`getInheritableProperty: maximum loop count exceeded for "${key}"`);
|
||||
break;
|
||||
}
|
||||
dict = dict.get('Parent');
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
const ROMAN_NUMBER_MAP = [
|
||||
'', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM',
|
||||
'', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC',
|
||||
'', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'
|
||||
];
|
||||
|
||||
/**
|
||||
* Converts positive integers to (upper case) Roman numerals.
|
||||
* @param {integer} number - The number that should be converted.
|
||||
* @param {boolean} lowerCase - Indicates if the result should be converted
|
||||
* to lower case letters. The default value is `false`.
|
||||
* @return {string} The resulting Roman number.
|
||||
*/
|
||||
function toRomanNumerals(number, lowerCase = false) {
|
||||
assert(Number.isInteger(number) && number > 0,
|
||||
'The number should be a positive integer.');
|
||||
let pos, romanBuf = [];
|
||||
// Thousands
|
||||
while (number >= 1000) {
|
||||
number -= 1000;
|
||||
romanBuf.push('M');
|
||||
}
|
||||
// Hundreds
|
||||
pos = (number / 100) | 0;
|
||||
number %= 100;
|
||||
romanBuf.push(ROMAN_NUMBER_MAP[pos]);
|
||||
// Tens
|
||||
pos = (number / 10) | 0;
|
||||
number %= 10;
|
||||
romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
|
||||
// Ones
|
||||
romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
|
||||
|
||||
const romanStr = romanBuf.join('');
|
||||
return (lowerCase ? romanStr.toLowerCase() : romanStr);
|
||||
}
|
||||
|
||||
export {
|
||||
getLookupTableFactory,
|
||||
MissingDataException,
|
||||
XRefEntryException,
|
||||
XRefParseException,
|
||||
getInheritableProperty,
|
||||
toRomanNumerals,
|
||||
};
|
|
@ -15,12 +15,15 @@
|
|||
/* eslint no-var: error */
|
||||
|
||||
import {
|
||||
assert, FormatError, getInheritableProperty, info, isArrayBuffer, isBool,
|
||||
isNum, isSpace, isString, MissingDataException, OPS, shadow, stringToBytes,
|
||||
stringToPDFString, Util, warn, XRefEntryException, XRefParseException
|
||||
assert, FormatError, info, isArrayBuffer, isBool, isNum, isSpace, isString,
|
||||
OPS, shadow, stringToBytes, stringToPDFString, Util, warn
|
||||
} from '../shared/util';
|
||||
import { Catalog, ObjectLoader, XRef } from './obj';
|
||||
import { Dict, isDict, isName, isStream, Ref } from './primitives';
|
||||
import {
|
||||
getInheritableProperty, MissingDataException, XRefEntryException,
|
||||
XRefParseException
|
||||
} from './core_utils';
|
||||
import { NullStream, Stream, StreamsSequenceStream } from './stream';
|
||||
import { AnnotationFactory } from './annotation';
|
||||
import { calculateMD5 } from './crypto';
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
import {
|
||||
AbortException, assert, CMapCompressionType, createPromiseCapability,
|
||||
FONT_IDENTITY_MATRIX, FormatError, getLookupTableFactory, IDENTITY_MATRIX,
|
||||
info, isNum, isString, NativeImageDecoding, OPS, stringToPDFString,
|
||||
TextRenderingMode, UNSUPPORTED_FEATURES, Util, warn
|
||||
FONT_IDENTITY_MATRIX, FormatError, IDENTITY_MATRIX, info, isNum, isString,
|
||||
NativeImageDecoding, OPS, stringToPDFString, TextRenderingMode,
|
||||
UNSUPPORTED_FEATURES, Util, warn
|
||||
} from '../shared/util';
|
||||
import { CMapFactory, IdentityCMap } from './cmap';
|
||||
import { DecodeStream, Stream } from './stream';
|
||||
|
@ -42,6 +42,7 @@ import { Lexer, Parser } from './parser';
|
|||
import { bidi } from './bidi';
|
||||
import { ColorSpace } from './colorspace';
|
||||
import { getGlyphsUnicode } from './glyphlist';
|
||||
import { getLookupTableFactory } from './core_utils';
|
||||
import { getMetrics } from './metrics';
|
||||
import { isPDFFunction } from './function';
|
||||
import { JpegStream } from './jpeg_stream';
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
|
||||
import {
|
||||
assert, bytesToString, FONT_IDENTITY_MATRIX, FontType, FormatError, info,
|
||||
isNum, isSpace, MissingDataException, readUint32, shadow, string32,
|
||||
unreachable, warn
|
||||
isNum, isSpace, readUint32, shadow, string32, unreachable, warn
|
||||
} from '../shared/util';
|
||||
import {
|
||||
CFF, CFFCharset, CFFCompiler, CFFHeader, CFFIndex, CFFParser, CFFPrivateDict,
|
||||
|
@ -36,6 +35,7 @@ import {
|
|||
} from './unicode';
|
||||
import { FontRendererFactory } from './font_renderer';
|
||||
import { IdentityCMap } from './cmap';
|
||||
import { MissingDataException } from './core_utils';
|
||||
import { Stream } from './stream';
|
||||
import { Type1Parser } from './type1_parser';
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
/* no-babel-preset */
|
||||
|
||||
var getLookupTableFactory = require('../shared/util').getLookupTableFactory;
|
||||
var getLookupTableFactory = require('./core_utils').getLookupTableFactory;
|
||||
|
||||
var getGlyphsUnicode = getLookupTableFactory(function (t) {
|
||||
t['A'] = 0x0041;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { getLookupTableFactory } from '../shared/util';
|
||||
import { getLookupTableFactory } from './core_utils';
|
||||
|
||||
// The Metrics object contains glyph widths (in glyph space units).
|
||||
// As per PDF spec, for most fonts (Type 3 being an exception) a glyph
|
||||
|
|
|
@ -15,15 +15,17 @@
|
|||
|
||||
import {
|
||||
bytesToString, createPromiseCapability, createValidAbsoluteUrl, FormatError,
|
||||
info, InvalidPDFException, isBool, isNum, isString, MissingDataException,
|
||||
PermissionFlag, shadow, stringToPDFString, stringToUTF8String,
|
||||
toRomanNumerals, unreachable, warn, XRefEntryException, XRefParseException
|
||||
info, InvalidPDFException, isBool, isNum, isString, PermissionFlag, shadow,
|
||||
stringToPDFString, stringToUTF8String, unreachable, warn
|
||||
} from '../shared/util';
|
||||
import {
|
||||
Dict, isCmd, isDict, isName, isRef, isRefsEqual, isStream, Ref, RefSet,
|
||||
RefSetCache
|
||||
} from './primitives';
|
||||
import { Lexer, Parser } from './parser';
|
||||
import {
|
||||
MissingDataException, toRomanNumerals, XRefEntryException, XRefParseException
|
||||
} from './core_utils';
|
||||
import { ChunkedStream } from './chunked_stream';
|
||||
import { CipherTransformFactory } from './crypto';
|
||||
import { ColorSpace } from './colorspace';
|
||||
|
|
|
@ -19,7 +19,7 @@ import {
|
|||
} from './stream';
|
||||
import {
|
||||
assert, bytesToString, FormatError, info, isNum, isSpace, isString,
|
||||
MissingDataException, StreamType, warn
|
||||
StreamType, warn
|
||||
} from '../shared/util';
|
||||
import {
|
||||
Cmd, Dict, EOF, isCmd, isDict, isEOF, isName, Name, Ref
|
||||
|
@ -28,6 +28,7 @@ import { CCITTFaxStream } from './ccitt_stream';
|
|||
import { Jbig2Stream } from './jbig2_stream';
|
||||
import { JpegStream } from './jpeg_stream';
|
||||
import { JpxStream } from './jpx_stream';
|
||||
import { MissingDataException } from './core_utils';
|
||||
|
||||
const MAX_LENGTH_TO_CACHE = 1000;
|
||||
const MAX_ADLER32_LENGTH = 5552;
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
/* eslint-disable no-multi-spaces */
|
||||
|
||||
import {
|
||||
assert, FormatError, info, MissingDataException, unreachable,
|
||||
UNSUPPORTED_FEATURES, Util, warn
|
||||
assert, FormatError, info, unreachable, UNSUPPORTED_FEATURES, Util, warn
|
||||
} from '../shared/util';
|
||||
import { ColorSpace } from './colorspace';
|
||||
import { isStream } from './primitives';
|
||||
import { MissingDataException } from './core_utils';
|
||||
|
||||
var ShadingType = {
|
||||
FUNCTION_BASED: 1,
|
||||
|
|
|
@ -14,9 +14,10 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
createValidAbsoluteUrl, MissingDataException, shadow, unreachable, warn
|
||||
createValidAbsoluteUrl, shadow, unreachable, warn
|
||||
} from '../shared/util';
|
||||
import { ChunkedStreamManager } from './chunked_stream';
|
||||
import { MissingDataException } from './core_utils';
|
||||
import { PDFDocument } from './document';
|
||||
import { Stream } from './stream';
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
/* eslint no-var: error */
|
||||
|
||||
import { getLookupTableFactory } from '../shared/util';
|
||||
import { getLookupTableFactory } from './core_utils';
|
||||
|
||||
/**
|
||||
* Hold a map of decoded fonts and of the standard fourteen Type1
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
/* no-babel-preset */
|
||||
|
||||
var getLookupTableFactory = require('../shared/util').getLookupTableFactory;
|
||||
var getLookupTableFactory = require('./core_utils').getLookupTableFactory;
|
||||
|
||||
// Some characters, e.g. copyrightserif, are mapped to the private use area
|
||||
// and might not be displayed using standard fonts. Mapping/hacking well-known
|
||||
|
|
|
@ -17,12 +17,13 @@ import {
|
|||
arrayByteLength, arraysToBytes, assert, createPromiseCapability, info,
|
||||
InvalidPDFException, MissingPDFException, PasswordException,
|
||||
setVerbosityLevel, UnexpectedResponseException, UnknownErrorException,
|
||||
UNSUPPORTED_FEATURES, warn, XRefParseException
|
||||
UNSUPPORTED_FEATURES, warn
|
||||
} from '../shared/util';
|
||||
import { LocalPdfManager, NetworkPdfManager } from './pdf_manager';
|
||||
import isNodeJS from '../shared/is_node';
|
||||
import { MessageHandler } from '../shared/message_handler';
|
||||
import { Ref } from './primitives';
|
||||
import { XRefParseException } from './core_utils';
|
||||
|
||||
var WorkerTask = (function WorkerTaskClosure() {
|
||||
function WorkerTask(name) {
|
||||
|
|
|
@ -382,18 +382,6 @@ function shadow(obj, prop, value) {
|
|||
return value;
|
||||
}
|
||||
|
||||
function getLookupTableFactory(initializer) {
|
||||
var lookup;
|
||||
return function () {
|
||||
if (initializer) {
|
||||
lookup = Object.create(null);
|
||||
initializer(lookup);
|
||||
initializer = null;
|
||||
}
|
||||
return lookup;
|
||||
};
|
||||
}
|
||||
|
||||
var PasswordException = (function PasswordExceptionClosure() {
|
||||
function PasswordException(msg, code) {
|
||||
this.name = 'PasswordException';
|
||||
|
@ -458,44 +446,6 @@ var UnexpectedResponseException =
|
|||
return UnexpectedResponseException;
|
||||
})();
|
||||
|
||||
var MissingDataException = (function MissingDataExceptionClosure() {
|
||||
function MissingDataException(begin, end) {
|
||||
this.begin = begin;
|
||||
this.end = end;
|
||||
this.message = 'Missing data [' + begin + ', ' + end + ')';
|
||||
}
|
||||
|
||||
MissingDataException.prototype = new Error();
|
||||
MissingDataException.prototype.name = 'MissingDataException';
|
||||
MissingDataException.constructor = MissingDataException;
|
||||
|
||||
return MissingDataException;
|
||||
})();
|
||||
|
||||
const XRefEntryException = (function XRefEntryExceptionClosure() {
|
||||
function XRefEntryException(msg) {
|
||||
this.message = msg;
|
||||
}
|
||||
|
||||
XRefEntryException.prototype = new Error();
|
||||
XRefEntryException.prototype.name = 'XRefEntryException';
|
||||
XRefEntryException.constructor = XRefEntryException;
|
||||
|
||||
return XRefEntryException;
|
||||
})();
|
||||
|
||||
var XRefParseException = (function XRefParseExceptionClosure() {
|
||||
function XRefParseException(msg) {
|
||||
this.message = msg;
|
||||
}
|
||||
|
||||
XRefParseException.prototype = new Error();
|
||||
XRefParseException.prototype.name = 'XRefParseException';
|
||||
XRefParseException.constructor = XRefParseException;
|
||||
|
||||
return XRefParseException;
|
||||
})();
|
||||
|
||||
/**
|
||||
* Error caused during parsing PDF data.
|
||||
*/
|
||||
|
@ -659,53 +609,6 @@ function isEvalSupported() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of an inheritable property.
|
||||
*
|
||||
* If the PDF specification explicitly lists a property in a dictionary as
|
||||
* inheritable, then the value of the property may be present in the dictionary
|
||||
* itself or in one or more parents of the dictionary.
|
||||
*
|
||||
* If the key is not found in the tree, `undefined` is returned. Otherwise,
|
||||
* the value for the key is returned or, if `stopWhenFound` is `false`, a list
|
||||
* of values is returned. To avoid infinite loops, the traversal is stopped when
|
||||
* the loop limit is reached.
|
||||
*
|
||||
* @param {Dict} dict - Dictionary from where to start the traversal.
|
||||
* @param {string} key - The key of the property to find the value for.
|
||||
* @param {boolean} getArray - Whether or not the value should be fetched as an
|
||||
* array. The default value is `false`.
|
||||
* @param {boolean} stopWhenFound - Whether or not to stop the traversal when
|
||||
* the key is found. If set to `false`, we always walk up the entire parent
|
||||
* chain, for example to be able to find `\Resources` placed on multiple
|
||||
* levels of the tree. The default value is `true`.
|
||||
*/
|
||||
function getInheritableProperty({ dict, key, getArray = false,
|
||||
stopWhenFound = true, }) {
|
||||
const LOOP_LIMIT = 100;
|
||||
let loopCount = 0;
|
||||
let values;
|
||||
|
||||
while (dict) {
|
||||
const value = getArray ? dict.getArray(key) : dict.get(key);
|
||||
if (value !== undefined) {
|
||||
if (stopWhenFound) {
|
||||
return value;
|
||||
}
|
||||
if (!values) {
|
||||
values = [];
|
||||
}
|
||||
values.push(value);
|
||||
}
|
||||
if (++loopCount > LOOP_LIMIT) {
|
||||
warn(`getInheritableProperty: maximum loop count exceeded for "${key}"`);
|
||||
break;
|
||||
}
|
||||
dict = dict.get('Parent');
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
var Util = (function UtilClosure() {
|
||||
function Util() {}
|
||||
|
||||
|
@ -866,43 +769,6 @@ var Util = (function UtilClosure() {
|
|||
return Util;
|
||||
})();
|
||||
|
||||
const ROMAN_NUMBER_MAP = [
|
||||
'', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM',
|
||||
'', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC',
|
||||
'', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'
|
||||
];
|
||||
|
||||
/**
|
||||
* Converts positive integers to (upper case) Roman numerals.
|
||||
* @param {integer} number - The number that should be converted.
|
||||
* @param {boolean} lowerCase - Indicates if the result should be converted
|
||||
* to lower case letters. The default value is `false`.
|
||||
* @return {string} The resulting Roman number.
|
||||
*/
|
||||
function toRomanNumerals(number, lowerCase = false) {
|
||||
assert(Number.isInteger(number) && number > 0,
|
||||
'The number should be a positive integer.');
|
||||
let pos, romanBuf = [];
|
||||
// Thousands
|
||||
while (number >= 1000) {
|
||||
number -= 1000;
|
||||
romanBuf.push('M');
|
||||
}
|
||||
// Hundreds
|
||||
pos = (number / 100) | 0;
|
||||
number %= 100;
|
||||
romanBuf.push(ROMAN_NUMBER_MAP[pos]);
|
||||
// Tens
|
||||
pos = (number / 10) | 0;
|
||||
number %= 10;
|
||||
romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
|
||||
// Ones
|
||||
romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
|
||||
|
||||
const romanStr = romanBuf.join('');
|
||||
return (lowerCase ? romanStr.toLowerCase() : romanStr);
|
||||
}
|
||||
|
||||
const PDFStringTranslateTable = [
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0x2D8, 0x2C7, 0x2C6, 0x2D9, 0x2DD, 0x2DB, 0x2DA, 0x2DC, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
@ -1046,7 +912,6 @@ export {
|
|||
CMapCompressionType,
|
||||
AbortException,
|
||||
InvalidPDFException,
|
||||
MissingDataException,
|
||||
MissingPDFException,
|
||||
NativeImageDecoding,
|
||||
PasswordException,
|
||||
|
@ -1057,9 +922,6 @@ export {
|
|||
UnexpectedResponseException,
|
||||
UnknownErrorException,
|
||||
Util,
|
||||
toRomanNumerals,
|
||||
XRefEntryException,
|
||||
XRefParseException,
|
||||
FormatError,
|
||||
arrayByteLength,
|
||||
arraysToBytes,
|
||||
|
@ -1068,8 +930,6 @@ export {
|
|||
createPromiseCapability,
|
||||
createObjectURL,
|
||||
deprecated,
|
||||
getInheritableProperty,
|
||||
getLookupTableFactory,
|
||||
getVerbosityLevel,
|
||||
info,
|
||||
isArrayBuffer,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue