Merge pull request #14648 from Snuffleupagus/PDFDocument-stream
Simplify the `PDFDocument` constructor
This commit is contained in:
commit
55a931e454
@ -18,7 +18,6 @@ import {
|
|||||||
FormatError,
|
FormatError,
|
||||||
info,
|
info,
|
||||||
InvalidPDFException,
|
InvalidPDFException,
|
||||||
isArrayBuffer,
|
|
||||||
isArrayEqual,
|
isArrayEqual,
|
||||||
OPS,
|
OPS,
|
||||||
PageActionEventType,
|
PageActionEventType,
|
||||||
@ -43,13 +42,13 @@ import {
|
|||||||
} from "./core_utils.js";
|
} from "./core_utils.js";
|
||||||
import { Dict, isName, Name, Ref } from "./primitives.js";
|
import { Dict, isName, Name, Ref } from "./primitives.js";
|
||||||
import { getXfaFontDict, getXfaFontName } from "./xfa_fonts.js";
|
import { getXfaFontDict, getXfaFontName } from "./xfa_fonts.js";
|
||||||
import { NullStream, Stream } from "./stream.js";
|
|
||||||
import { AnnotationFactory } from "./annotation.js";
|
import { AnnotationFactory } from "./annotation.js";
|
||||||
import { BaseStream } from "./base_stream.js";
|
import { BaseStream } from "./base_stream.js";
|
||||||
import { calculateMD5 } from "./crypto.js";
|
import { calculateMD5 } from "./crypto.js";
|
||||||
import { Catalog } from "./catalog.js";
|
import { Catalog } from "./catalog.js";
|
||||||
import { clearGlobalCaches } from "./cleanup_helper.js";
|
import { clearGlobalCaches } from "./cleanup_helper.js";
|
||||||
import { Linearization } from "./parser.js";
|
import { Linearization } from "./parser.js";
|
||||||
|
import { NullStream } from "./stream.js";
|
||||||
import { ObjectLoader } from "./object_loader.js";
|
import { ObjectLoader } from "./object_loader.js";
|
||||||
import { OperatorList } from "./operator_list.js";
|
import { OperatorList } from "./operator_list.js";
|
||||||
import { PartialEvaluator } from "./evaluator.js";
|
import { PartialEvaluator } from "./evaluator.js";
|
||||||
@ -625,14 +624,15 @@ function find(stream, signature, limit = 1024, backwards = false) {
|
|||||||
* The `PDFDocument` class holds all the (worker-thread) data of the PDF file.
|
* The `PDFDocument` class holds all the (worker-thread) data of the PDF file.
|
||||||
*/
|
*/
|
||||||
class PDFDocument {
|
class PDFDocument {
|
||||||
constructor(pdfManager, arg) {
|
constructor(pdfManager, stream) {
|
||||||
let stream;
|
if (
|
||||||
if (arg instanceof BaseStream) {
|
typeof PDFJSDev === "undefined" ||
|
||||||
stream = arg;
|
PDFJSDev.test("!PRODUCTION || TESTING")
|
||||||
} else if (isArrayBuffer(arg)) {
|
) {
|
||||||
stream = new Stream(arg);
|
assert(
|
||||||
} else {
|
stream instanceof BaseStream,
|
||||||
throw new Error("PDFDocument: Unknown argument type");
|
'PDFDocument: Invalid "stream" argument.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (stream.length <= 0) {
|
if (stream.length <= 0) {
|
||||||
throw new InvalidPDFException(
|
throw new InvalidPDFException(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user