Hummusjs: Appending from PDF ignoring page range

Created on 30 Nov 2016  路  4Comments  路  Source: galkahana/HummusJS

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();

Most helpful comment

oh. and it should be:
pdfWriter.appendPDFPagesFromPDF(sourcePDF,{type:hummus.eRangeTypeSpecific,specificRanges: [ [ 1,3 ],[ 7,10 ] ]});

All 4 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cortopy picture cortopy  路  4Comments

kevincollins7 picture kevincollins7  路  4Comments

richard-kurtosys picture richard-kurtosys  路  5Comments

Barnie picture Barnie  路  8Comments

MOuli90 picture MOuli90  路  6Comments