nbesli/pdf-merger-js

The guard for enough pages in _addFromToPage uses the wrong operator

uriroos opened this issue · 0 comments

The function _addFromToPage has a guard for checking if there are enough pages available in the original file. However at this point the page index being using is still 1 based. The operator being used in the guard is for 0 based index >=.

Steps to reproduce

  1. Create a pdf of 2 pages
  2. Call .add with the range 1-2
  3. Call .save

Expected behaviour
Two pages are being added to the merged pdf.

Seen behaviour
The pdf is not created but an error thrown: Invalid function parameter. The document has not enought pages. (from:1, to:2, pages:2)