Hi! Thank you for developing pdfassembler, it's exactly what I need.
I've got a problem with your minimal working example from the Readme.md. I use Browserify and Babel to support all browsers and to use
var PDFAssembler = require('pdfassembler').PDFAssembler;
on the client side.
This is my code:
await Promise.all(pdfFiles.map(async (f) => {
const helloWorldPdf = {
'/Root': {
'/Type': '/Catalog',
'/Pages': {
'/Type': '/Pages',
'/Count': 1,
'/Kids': [ {
'/Type': '/Page',
'/MediaBox': [ 0, 0, 612, 792 ],
'/Contents': [ {
'stream': '1 0 0 1 72 708 cm BT /Helv 12 Tf (Hello world!) Tj ET'
} ],
'/Resources': {
'/Font': {
'/Helv': {
'/Type': '/Font',
'/BaseFont': '/Helvetica',
'/Subtype': '/Type1'
}
}
},
} ],
}
}
}
const pdfAssemblerObj = new PDFAssembler(helloWorldPdf);
pdfAssemblerObj
.pdfObject()
.then(function(pdf) {
pdf['/Root']['/Pages']['/Kids'] = pdf['/Root']['/Pages']['/Kids'].slice(0, 1);
});
await pdfAssemblerObj.removeRootEntries();
out_pdfs.push(await pdfAssemblerObj.assemblePdf(f.filename));
}));
Whenever I try to execute it, it throws the error
Unhandled promise rejection
TypeError: pdfAssemblerObj.pdfObject is not a function
in firefox (just the beginning of the error) and
Uncaught (in promise) TypeError: pdfAssemblerObj.pdfObject is not a function
at _callee16$ (bundle.js:55304)
at tryCatch (polyfill.min.js:4)
at Generator.invoke [as _invoke] (polyfill.min.js:4)
at Generator.t.(:3000/anonymous function) [as next] (https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.26.0/polyfill.min.js:4:1671)
at step (bundle.js:55383)
at bundle.js:55383
at new Promise (<anonymous>)
at bundle.js:55383
at bundle.js:55335
at Array.map (<anonymous>)
in chrome. When I print out the pdfAssemblerObj using
const pdfAssemblerObj = new PDFAssembler(helloWorldPdf);
console.log(pdfAssemblerObj);
it gives me the object
{
"pdfManager": null,
"userPassword": "",
"ownerPassword": "",
"nextNodeNum": 1,
"pdfTree": {
"/Root": {
"/Type": "/Catalog",
"/Pages": {
"/Type": "/Pages",
"/Count": 1,
"/Kids": [
{
"/Type": "/Page",
"/MediaBox": [
0,
0,
612,
792
],
"/Contents": [
{
"stream": "1 0 0 1 72 708 cm BT /Helv 12 Tf (Hello world!) Tj ET"
}
],
"/Resources": {
"/Font": {
"/Helv": {
"/Type": "/Font",
"/BaseFont": "/Helvetica",
"/Subtype": "/Type1"
}
}
}
}
]
}
}
},
"recoveryMode": false,
"objCache": {},
"objCacheQueue": {},
"pdfManagerArrays": [],
"pdfAssemblerArrays": [],
"promiseQueue": {
"options": {},
"pendingPromises": 0,
"maxPendingPromises": 1,
"maxQueuedPromises": null,
"queue": []
},
"indent": false,
"compress": true,
"encrypt": false,
"groupPages": true,
"pageGroupSize": 16,
"pdfVersion": "1.7"
}
Did you change anything about the API? Or what did I do wrong?
Edit: I don't use TypeScript. Could that be a problem?
Hi! Thank you for developing pdfassembler, it's exactly what I need.
I've got a problem with your minimal working example from the Readme.md. I use Browserify and Babel to support all browsers and to use
on the client side.
This is my code:
Whenever I try to execute it, it throws the error
in firefox (just the beginning of the error) and
in chrome. When I print out the
pdfAssemblerObjusingit gives me the object
{ "pdfManager": null, "userPassword": "", "ownerPassword": "", "nextNodeNum": 1, "pdfTree": { "/Root": { "/Type": "/Catalog", "/Pages": { "/Type": "/Pages", "/Count": 1, "/Kids": [ { "/Type": "/Page", "/MediaBox": [ 0, 0, 612, 792 ], "/Contents": [ { "stream": "1 0 0 1 72 708 cm BT /Helv 12 Tf (Hello world!) Tj ET" } ], "/Resources": { "/Font": { "/Helv": { "/Type": "/Font", "/BaseFont": "/Helvetica", "/Subtype": "/Type1" } } } } ] } } }, "recoveryMode": false, "objCache": {}, "objCacheQueue": {}, "pdfManagerArrays": [], "pdfAssemblerArrays": [], "promiseQueue": { "options": {}, "pendingPromises": 0, "maxPendingPromises": 1, "maxQueuedPromises": null, "queue": [] }, "indent": false, "compress": true, "encrypt": false, "groupPages": true, "pageGroupSize": 16, "pdfVersion": "1.7" }Did you change anything about the API? Or what did I do wrong?
Edit: I don't use TypeScript. Could that be a problem?