Scaffolding for PDF salad
This commit is contained in:
3
projects/pdf-salad/.gitignore
vendored
Normal file
3
projects/pdf-salad/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
node_modules/
|
||||
index.js
|
||||
out.pdf
|
6
projects/pdf-salad/build.hxml
Normal file
6
projects/pdf-salad/build.hxml
Normal file
@@ -0,0 +1,6 @@
|
||||
-lib kiss
|
||||
-lib hxnodejs
|
||||
-cp src
|
||||
--main Main
|
||||
-js index.js
|
||||
--cmd node index.js example-input
|
1772
projects/pdf-salad/example-input/antique-phone-shop.pdf
Normal file
1772
projects/pdf-salad/example-input/antique-phone-shop.pdf
Normal file
File diff suppressed because it is too large
Load Diff
1631
projects/pdf-salad/example-input/smashbrosgo.pdf
Normal file
1631
projects/pdf-salad/example-input/smashbrosgo.pdf
Normal file
File diff suppressed because it is too large
Load Diff
43
projects/pdf-salad/package-lock.json
generated
Normal file
43
projects/pdf-salad/package-lock.json
generated
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"requires": true,
|
||||
"lockfileVersion": 1,
|
||||
"dependencies": {
|
||||
"@pdf-lib/standard-fonts": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@pdf-lib/standard-fonts/-/standard-fonts-1.0.0.tgz",
|
||||
"integrity": "sha512-hU30BK9IUN/su0Mn9VdlVKsWBS6GyhVfqjwl1FjZN4TxP6cCw0jP2w7V3Hf5uX7M0AZJ16vey9yE0ny7Sa59ZA==",
|
||||
"requires": {
|
||||
"pako": "^1.0.6"
|
||||
}
|
||||
},
|
||||
"@pdf-lib/upng": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@pdf-lib/upng/-/upng-1.0.1.tgz",
|
||||
"integrity": "sha512-dQK2FUMQtowVP00mtIksrlZhdFXQZPC+taih1q4CvPZ5vqdxR/LKBaFg0oAfzd1GlHZXXSPdQfzQnt+ViGvEIQ==",
|
||||
"requires": {
|
||||
"pako": "^1.0.10"
|
||||
}
|
||||
},
|
||||
"pako": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz",
|
||||
"integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw=="
|
||||
},
|
||||
"pdf-lib": {
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://registry.npmjs.org/pdf-lib/-/pdf-lib-1.12.0.tgz",
|
||||
"integrity": "sha512-5gqG/w8QMhl/NfzqqIt1WddVHnW3kr+J/2LadP3GT0jAdGKoB0l4h/C4pzzK40b0AlBe2fr1Mvo9ZfR24set5A==",
|
||||
"requires": {
|
||||
"@pdf-lib/standard-fonts": "^1.0.0",
|
||||
"@pdf-lib/upng": "^1.0.1",
|
||||
"pako": "^1.0.11",
|
||||
"tslib": "^1.11.1"
|
||||
}
|
||||
},
|
||||
"tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
|
||||
}
|
||||
}
|
||||
}
|
11
projects/pdf-salad/src/Externs.hx
Normal file
11
projects/pdf-salad/src/Externs.hx
Normal file
@@ -0,0 +1,11 @@
|
||||
package;
|
||||
|
||||
import js.node.Buffer;
|
||||
import js.lib.Promise;
|
||||
|
||||
@:jsRequire("pdf-lib", "PDFDocument")
|
||||
extern class PDFDocument {
|
||||
public static function create():Promise<PDFDocument>;
|
||||
public static function load(bytes:Buffer):Promise<PDFDocument>;
|
||||
public function save():Promise<Buffer>;
|
||||
}
|
10
projects/pdf-salad/src/Main.hx
Normal file
10
projects/pdf-salad/src/Main.hx
Normal file
@@ -0,0 +1,10 @@
|
||||
package;
|
||||
|
||||
import js.lib.Uint8Array;
|
||||
import js.node.Fs;
|
||||
import kiss.Kiss;
|
||||
import kiss.Prelude;
|
||||
import Externs;
|
||||
|
||||
@:build(kiss.Kiss.build("src/Main.kiss"))
|
||||
class Main {}
|
5
projects/pdf-salad/src/Main.kiss
Normal file
5
projects/pdf-salad/src/Main.kiss
Normal file
@@ -0,0 +1,5 @@
|
||||
(defun main []
|
||||
(let [bytesIn (Fs.readFileSync "example-input/antique-phone-shop.pdf")]
|
||||
(.then (PDFDocument.load bytesIn) (lambda [pdfToModify]
|
||||
(.then (pdfToModify.save) (lambda [bytesOut]
|
||||
(Fs.writeFileSync "out.pdf" bytesOut)))))))
|
7
projects/pdf-salad/test.sh
Normal file
7
projects/pdf-salad/test.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#! /bin/bash
|
||||
|
||||
if [ ! -z "$TRAVIS_OS_NAME" ]; then
|
||||
npm install pdf-lib
|
||||
fi
|
||||
haxelib dev kiss ../../
|
||||
haxe build.hxml
|
Reference in New Issue
Block a user