Page selector and Split scheme

For some features, it is very important to have a flexible option to determine which pages to process and which pages not to process (e.g. all even pages, all odd pages, only the first two and the last pages or every 4th page, etc.). For this purpose, a flexible syntax is used to express the desired groups of pages or page ranges.

A page selector expression can be a list e.g. 1,2,3. It can also be a simple expression, e.g. 3--3 will find all pages except the first and last two (last page being -1). Or it uses more advanced syntax: e.g. *3 will select every third page. More information below.

"page_selector": "all|even|odd|<splitscheme_expression>"
Click to copy

Split scheme is a TYPE of 'page selector'

Usage on CLI

The “Page selector” functionality can be used on CLI in the following way:

--pagerange=<expression>
Click to copy

This is the same syntax as used for split schemes (--splitscheme=<expression>)

Usage in the SDK

The “Page selector” functionality can be used in the SDK where the following parameter is listed (with slightly different types in other languages).

const PTB_sys_char_t*         pageselector         /*!< Use page selector syntax, might be NULL for all pages */
Click to copy

Split Scheme

A split scheme expression may be a number with an asterisk "*" or a more complex string. If it is a number with an asterisk "*", it creates groups of pages where each group has the defined number of pages. E.g. if the expression is "3*" it would group the PDF into groups of 3 pages.

Expressions

Type Syntax Example

Simple expression

number[-number]
1-5

Page 1 to 5: [1,2,3,4,5]



5-1

Page 5 to 1: [5,4,3,2,1]



8 Only page 8


-1 Last page


-3--1

Last 3 pages: [n, n-1, n-2]



-1--3

Last 3 pages in reverse order: [n-2, n-1, n]



-1-3

Last n - 2 pages in reverse order: [n, n-1, ... ,3]

Type
Syntax
Example

Simple expression with Simple Range

number[-number]_ number[-number][ "," joker$]

1-2_-2--1

First 2 and last 2 pages: [1,2,n- 1,n]



1-2_-2--1,$

First 2 and last 2 pages [1,2,n-1,n] and remaining inner pages [3, ... ,n-2]



1_1_1_1

4 times page 1: [1,1,1,1]

Type Syntax Example

Multipage expression

even_pages

even

All even pages(same as *2(2))


uneven_pages
odd

All odd pages (same as *2(1))


Package number* [(start_page)]

5*

Packages of 5 pages



5*(2)

Packages of 5 pages, starting with page 2


*number [(start_page)]

*5
Every 5th page


*5(2)

Every 5th page, starting with page 2



*5(-20)

Every 5th page of the last 20 pages of a document (total 4 pages)


*number [(start_page,end_page)]
*5(2,20)
Every 5th page starting with the second page and up to the 20th page
Type Syntax
Example

Simple expression list

simple_expression {"," simple_expression}[ "," joker$]

1-5,8,-3--1

1 PDF with pages 1-5, page 8 and the last 3 pages of the input PDF



1-5,8,-1--3

1 PDF with pages 1-5, page 8 and the last 3 pages of the input PDF, but the last 3 pages in reverse order



1-5,8,$
1 PDF with pages 1-5, page 8 and all the remaining pages

Joker

<expression>,$
Click to copy

Can be combined with other expressions (has to be the last item in a list) in order to group all pages that are not part of any other expression into their own group.

Example

1-5,8,-3--1,$
Click to copy

would create groups of pages with pages 1-5, page 8, the last 3 pages and the rest of the pages of the PDF.