Trying to copy a specific range of pages from the source PDF. The documentation shows an optional second parameter to the appendPDFPagesFromPDF() function to specify a range of pages.
Regardless of the range specified, or even if the parameter is present, I get a full copy of the source PDF.
The following code blocks generate the same resulting PDF (the source PDF has about 2000 pages):
var path = require('path');
var hummus = require('hummus');
var sourcePDF = path.join(__dirname, 'source.pdf');
var pdfWriter = hummus.createWriter(__dirname + '/test.pdf');
pdfWriter.appendPDFPagesFromPDF(sourcePDF, [ [ 1,3 ],[ 7,10 ] ]);
pdfWriter.end();
var path = require('path');
var hummus = require('hummus');
var sourcePDF = path.join(__dirname, 'source.pdf');
var pdfWriter = hummus.createWriter(__dirname + '/test.pdf');
pdfWriter.appendPDFPagesFromPDF(sourcePDF);
pdfWriter.end();
k. quick note before i look at it - consider using a PDFCopyingContext then. you can then copy each PDF page in a loop. behind the scenes its implemented in the same way.
about copying context - https://github.com/galkahana/HummusJS/wiki/Embedding-pdf#advanced-pdf-embedding-with-documentcopyingcontext
oh. and it should be:
pdfWriter.appendPDFPagesFromPDF(sourcePDF,{type:hummus.eRangeTypeSpecific,specificRanges: [ [ 1,3 ],[ 7,10 ] ]});
Bingo. My syntax was incorrect. Clearly I didn't read the documentation close enough. My Bad. Perhaps add an example for this scenario? Regardless, makes sense now.
Reason able, i will provide
Most helpful comment
oh. and it should be:
pdfWriter.appendPDFPagesFromPDF(sourcePDF,{type:hummus.eRangeTypeSpecific,specificRanges: [ [ 1,3 ],[ 7,10 ] ]});