Open shivarajnaidu opened 4 years ago
This method is pretty straightforward:
pdftk
.input('./multiPage.pdf')
.burst()
.then(() => {
// There is no output - files will be created in working directory
// You'll have to use 'fs' to read them here
})
Unfortunately, this method has no output - it just writes the files in the working directory. For now, you'll have to read the files manually after creation.
In the future, I'd like to enhance this method to automatically retrieve the new files and return them but don't have the time right now. Pull requests are always welcome, though.
I really need this feature. I am working on ArrayBuffers.
I will try to extend it but can't promise success.
Ok. I can't handle with this problem, but at least updated dependencies.
How burst works:
$ ls
document1.pdf
$ pdftk document1.pdf burst
$ ls
doc_data.txt document1.pdf pg_0001.pdf pg_0002.pdf pg_0003.pdf pg_0004.pdf pg_0005.pdf
but command
pdftk
.input('./multiPage.pdf')
.burst()
.then(() => {
// There is no output - files will be created in working directory
// You'll have to use 'fs' to read them here
})
creates files in main directory where server is running.
There is proposed info how to change location of output
https://stackoverflow.com/questions/6598937/set-output-location-for-pdftk-sample-pdf-burst
pdftk your_file.pdf burst output your_directory/page_%02d.pdf
But in our package both
returns promise, when at least one of them should return this
object.
Or we can add arguments to burst
that will redirect these files to directory selected by user.
Also wee need option that allow to receive array of buffers in promise resolved by burst.
@gustawdaniel Thanks for pointing that out. You can actually pass the output argument to the burst method:
pdftk
.input(pdf)
.burst('./your/file/path/page_%02d.pdf')
.then(()=> {
})
Hi @jjwilly16
I fixed it now! I will write docs and send pull request to check for you.
I done it exactly like you commented and extended burst by second argument with saved backward compatibility.
https://github.com/jjwilly16/node-pdftk/pull/40
Please for review.
Any sample code snippet to use this package to split the pdf into separate pages ? It will be very useful if we can get one ..
Thank you !