-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
2,369 additions
and
6,570 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@bsorrentino/pdf-tools", | ||
"version": "0.5.2", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"bin": { | ||
|
@@ -17,25 +17,24 @@ | |
"author": "bsorrentino <[email protected]> (http://soulsoftware-bsc.blogspot.it/)", | ||
"license": "MIT", | ||
"dependencies": { | ||
"canvas": "^2.6.1", | ||
"commander": "^6.2.0", | ||
"canvas": "^2.9.1", | ||
"commander": "^9.1.0", | ||
"enumify": "^2.0.0", | ||
"jimp": "^0.16.1", | ||
"pdfjs-dist": "^2.6.347" | ||
"pdfjs-dist": "^2.13.216" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^26.0.22", | ||
"@types/node": "^10.17.44", | ||
"@types/pdfjs-dist": "^2.7.1", | ||
"@types/jest": "^27.4.1", | ||
"@types/node": "^16.11.26", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"jest": "^26.6.3", | ||
"jest": "^27.5.1", | ||
"standard-version": "^9.3.2", | ||
"ts-jest": "^26.5.5", | ||
"typescript": "^4.0.5", | ||
"zx": "^6.0.1" | ||
"ts-jest": "^27.1.3", | ||
"typescript": "^4.6.2", | ||
"zx": "^6.0.6" | ||
}, | ||
"engines": { | ||
"node": ">=14" | ||
"node": ">=16" | ||
}, | ||
"config": { | ||
"commitizen": { | ||
|
@@ -45,6 +44,19 @@ | |
"standard-version": { | ||
"skip": { | ||
"tag": true | ||
}, | ||
"types": [ | ||
{"type": "feat", "section": "Features"}, | ||
{"type": "fix", "section": "Bug Fixes"}, | ||
{"type": "chore", "hidden": true}, | ||
{"type": "docs", "section": "Documentation"}, | ||
{"type": "style", "hidden": true}, | ||
{"type": "refactor", "section": "Refactoring"}, | ||
{"type": "perf", "hidden": true}, | ||
{"type": "test", "hidden": true}, | ||
{"type": "build", "section": "Build"} | ||
], | ||
"commitUrlFormat": "https://github.com/mokkapps/changelog-generator-demo/commits/{{hash}}", | ||
"compareUrlFormat": "https://github.com/mokkapps/changelog-generator-demo/compare/{{previousTag}}...{{currentTag}}" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ | ||
* | ||
* @ref https://github.com/mozilla/pdf.js/blob/master/examples/node/getinfo.js | ||
*/ | ||
|
||
// | ||
// Basic node example that prints document metadata and text content. | ||
// Requires single file built version of PDF.js -- please run | ||
// `gulp singlefile` before running the example. | ||
// | ||
|
||
// Run `gulp dist-install` to generate 'pdfjs-dist' npm package files. | ||
const pdfjsLib = require("pdfjs-dist/legacy/build/pdf.js"); | ||
|
||
// Loading file from file system into typed array | ||
const pdfPath = | ||
process.argv[2] || "samples/article-with-links.pdf"; | ||
|
||
// Will be using promises to load document, pages and misc data instead of | ||
// callback. | ||
const loadingTask = pdfjsLib.getDocument(pdfPath); | ||
loadingTask.promise | ||
.then(function (doc) { | ||
const numPages = doc.numPages; | ||
console.log("# Document Loaded"); | ||
console.log("Number of Pages: " + numPages); | ||
console.log(); | ||
|
||
let lastPromise; // will be used to chain promises | ||
lastPromise = doc.getMetadata().then(function (data) { | ||
console.log("# Metadata Is Loaded"); | ||
console.log("## Info"); | ||
console.log(JSON.stringify(data.info, null, 2)); | ||
console.log(); | ||
if (data.metadata) { | ||
console.log("## Metadata"); | ||
console.log(JSON.stringify(data.metadata.getAll(), null, 2)); | ||
console.log(); | ||
} | ||
}); | ||
|
||
const loadPage = function (pageNum) { | ||
return doc.getPage(pageNum).then(function (page) { | ||
console.log("# Page " + pageNum); | ||
const viewport = page.getViewport({ scale: 1.0 }); | ||
console.log("Size: " + viewport.width + "x" + viewport.height); | ||
console.log(); | ||
return page | ||
.getTextContent() | ||
.then(function (content) { | ||
// Content contains lots of information about the text layout and | ||
// styles, but we need only strings at the moment | ||
const strings = content.items.map(function (item) { | ||
return item.str; | ||
}); | ||
console.log("## Text Content"); | ||
console.log(strings.join(" ")); | ||
// Release page resources. | ||
page.cleanup(); | ||
}) | ||
.then(function () { | ||
console.log(); | ||
}); | ||
}); | ||
}; | ||
// Loading of the first page will wait on metadata and subsequent loadings | ||
// will wait on the previous pages. | ||
for (let i = 1; i <= numPages; i++) { | ||
lastPromise = lastPromise.then(loadPage.bind(null, i)); | ||
} | ||
return lastPromise; | ||
}) | ||
.then( | ||
function () { | ||
console.log("# End of Document"); | ||
}, | ||
function (err) { | ||
console.error("Error: " + err); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,7 +85,7 @@ | |
|
||
} | ||
|
||
type PDFLink = { | ||
declare type PDFLink = { | ||
x1:number | ||
y1:number | ||
x2:number | ||
|