Skip to content

Commit

Permalink
fix: avoid dynamic imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone Gosetto committed Sep 2, 2024
1 parent be091ac commit d93770e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
3 changes: 0 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ export = PdfParse;
declare function PdfParse(dataBuffer: Buffer, options?: PdfParse.Options): Promise<PdfParse.Result>;

declare namespace PdfParse {
// type Version = "default" | "v1.10.100" | "v2.0.550" | "v4.5.136";
interface Result {
numpages: number;
numrender: number;
info: any;
metadata: any;
// version: Version;
text: string;
}
interface Options {
pagerender?: ((pageData: any) => string) | undefined;
max?: number | undefined;
// version?: Version | undefined;
verbosityLevel?: 0 | 1 | 5 | undefined;
}
}
1 change: 0 additions & 1 deletion lib/pdf-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ async function PDF(dataBuffer, options) {
let doc = await PDFJS.getDocument({
verbosity: options.verbosityLevel ?? DEFAULT_OPTIONS.verbosityLevel,
data: new Uint8Array(dataBuffer),
enableXfa: false
}).promise;

ret.numpages = doc.numPages;
Expand Down
12 changes: 6 additions & 6 deletions lib/pdf.js/v4.5.136/build/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11004,17 +11004,17 @@ if (isNodeJS) {
var packageCapability = Promise.withResolvers();
var packageMap = null;
const loadPackages = async () => {
const fs = await import( /*webpackIgnore: true*/"fs"),
http = await import( /*webpackIgnore: true*/"http"),
https = await import( /*webpackIgnore: true*/"https"),
url = await import( /*webpackIgnore: true*/"url");
const fs = require( /*webpackIgnore: true*/"fs"),
http = require( /*webpackIgnore: true*/"http"),
https = require( /*webpackIgnore: true*/"https"),
url = require( /*webpackIgnore: true*/"url");
let canvas, path2d;
try {
canvas = await import( /*webpackIgnore: true*/"canvas");
canvas = require( /*webpackIgnore: true*/"canvas");
} catch {
}
try {
path2d = await import( /*webpackIgnore: true*/"path2d");
path2d = require( /*webpackIgnore: true*/"path2d");
} catch {
}
return new Map(Object.entries({
Expand Down

0 comments on commit d93770e

Please sign in to comment.