Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved page selection #2

Open
ajaxray opened this issue Jan 5, 2020 · 0 comments
Open

Improved page selection #2

ajaxray opened this issue Jan 5, 2020 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ajaxray
Copy link
Owner

ajaxray commented Jan 5, 2020

The Problem

Currently, this library supports the following format for specifying page numbers of input PDF document:

input-pdf-name.pdf~<page-number>[,<page-number>]*
That means comma-separated page numbers after the file name joined with a ~. For example -

merge2pdf output.pdf input1.pdf~1 input2.pdf input3.pdf~2,3,4

This will merge 1st page of input1.pdf, full input2.pdf and 2nd, 3rd, 4th page of input3.pdf.

So we have to mention every page number specifically. It's fine when the command is being executed from an application. But this is not an easy option in case of running the command manually, especially when we have a large number of pages.

Proposal for improvement

To make it easy to provide page numbers, we can add support for the following formats to specify input pages.

  1. Fixed range of inclusive sequence numbers separated with -.
    Example: 2-7 will mean 2nd to 7th pages
  2. Open-ended range. To indicate the last page, $ will be used as the anchor character.
    Example: 4-$ will mean 4th page to last page
  3. Combining page number formats. All supported formats (including current one) can be used combinedly
    Example: 1,2,5-7,11-$ will include 1,2,5,6,7 and 11 to last page

Notes:

  1. The current page number format is parsed in this function.
  2. Based on Merges pdf files #1 by @JohnnyMclain12
@ajaxray ajaxray added enhancement New feature or request good first issue Good for newcomers labels Jan 5, 2020
@ajaxray ajaxray mentioned this issue Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant