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

Add the End symbol to start somewhere and end at the end #127

Open
Ocyss opened this issue Dec 23, 2023 · 1 comment
Open

Add the End symbol to start somewhere and end at the end #127

Ocyss opened this issue Dec 23, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Ocyss
Copy link

Ocyss commented Dec 23, 2023

I want to start from a certain page to the end. I initially used regular expressions to replace end with 999999, but I found that this would cause an error. It exceeded the original page, so I initiated this issue.

I thought of an elegant solution. I can add an enforceMaxPage configuration to new PDFMerger() to enable the maximum number of pages to be used when the pages exceed the number of pages. Then I can also use end and start to represent the beginning and end.

// inputFile page = 5
const merger1 = new PDFMerger()
await merger1.add(inputFile, '2-9'); // throw Err

const merger2 = new PDFMerger({enforceMaxPage: true})
await merger2.add(inputFile, '2-9'); // 2,3,4,5
// inputFile page = 5
const merger = new PDFMerger()
await merger.add(inputFile, '2-End'); // 2,3,4,5
await merger.add(inputFile, '2-end'); // 2,3,4,5
await merger.add(inputFile, '3-e'); // 3,4,5
await merger.add(inputFile, 'start-end'); // 1,2,3,4,5
await merger.add(inputFile, 's-2'); // 1,2
@mojoaxel
Copy link
Collaborator

@Ocyss Thanks! This is a good idea!

@mojoaxel mojoaxel added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Dec 25, 2023
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 help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants