Changing pagelabels

Post Reply
User avatar
Terkelsen
Advanced member
Posts: 297
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Changing pagelabels

Post by Terkelsen »

I have a PDF containing 56 pages. I need to change the page labels for the pages 1-9 into 01, 02, 03 etc.
I have made this simple action that (is supposed to) select the page range 1-9 and add the change the page labels by adding 0 as a prefix.
Skærmbillede 2023-03-28 kl. 14.59.24.png
Skærmbillede 2023-03-28 kl. 14.59.24.png (151.73 KiB) Viewed 9336 times
Skærmbillede 2023-03-28 kl. 15.07.14.png
Skærmbillede 2023-03-28 kl. 15.07.14.png (119.19 KiB) Viewed 9336 times
But I can't get this to work. The selection of pages seems to have no effect. If I only do the "Change page labels" it works fine but obviously add a 0 to all page labels.

I have also tried to choose "Select pages with a page label in the list:" and add the numbers 1-9 to the list, but it makes no difference.

Am I missing something, or is this a bug?

PS: The reason for changing the pagelabels is that in Switch I need to split the PDF into single pages and add the page number as a suffix. If I use [Index] the suffix on all pages is two digets, but if I use [Label] the first nine pages are only one digit :roll:
User avatar
JimmyHartington
Advanced member
Posts: 278
Joined: Tue Mar 22, 2011 7:38 am

Re: Changing pagelabels

Post by JimmyHartington »

Could you do a regex rename on the filename in Switch?
Something like:
Search for: _(\d).pdf
Replace with: _0\1.pdf
User avatar
Terkelsen
Advanced member
Posts: 297
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Re: Changing pagelabels

Post by Terkelsen »

I tried that but the problem is that the file names contains several underscores followed by numbers and you can’t use regex look back in Switch.
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: Changing pagelabels

Post by freddyp »

I do not understand the problem. If you use [Index] the suffix on all pages is two digits, but it seems to me that that is what you want. What is the reason for wanting to use [Label]?

The reason why your Action List does not work is that you are selecting pages based on their labels, but I am 100% certain that the pages of your input file do not have labels so the pages do not get selected and nothing happens. You should use "Select pages" instead.
User avatar
JimmyHartington
Advanced member
Posts: 278
Joined: Tue Mar 22, 2011 7:38 am

Re: Changing pagelabels

Post by JimmyHartington »

Terkelsen wrote: Tue Mar 28, 2023 5:25 pm I tried that but the problem is that the file names contains several underscores followed by numbers and you can’t use regex look back in Switch.
But if the search includes the extension, then we find only the end of the filename, where there is an underscore, a digit and then .pdf.

Image
User avatar
Terkelsen
Advanced member
Posts: 297
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Re: Changing pagelabels

Post by Terkelsen »

@Jimmy. Almost ;) The search part seems to work fine, but using the replace part in "Search and replace" in the Rename element in Switch, seems to just remove the part of the filename?
Skærmbillede 2023-03-29 kl. 09.09.29.png
Skærmbillede 2023-03-29 kl. 09.09.29.png (31.82 KiB) Viewed 9294 times
@Freddy. The reason for using [Label] rather than [Index] is that at a certain time in the process, the PDF doesn't contain all pages. So the PDF for a 56 page magazine may only have 30 of the pages, but they all have the correct page label and the single PDF's need to be named with that page label as a suffix.
User avatar
JimmyHartington
Advanced member
Posts: 278
Joined: Tue Mar 22, 2011 7:38 am

Re: Changing pagelabels

Post by JimmyHartington »

Terkelsen wrote: Wed Mar 29, 2023 9:15 am @Jimmy. Almost ;) The search part seems to work fine, but using the replace part in "Search and replace" in the Rename element in Switch, seems to just remove the part of the filename?
I made an error. Different programs targets the search groups different. Sometimes $1 is the convention, but in Switch I found out it is \1.
So search for: _(\d)\.pdf
Replace with: _0\1.pdf
as regex.
Image
Last edited by JimmyHartington on Thu Mar 30, 2023 10:32 am, edited 1 time in total.
User avatar
Terkelsen
Advanced member
Posts: 297
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Re: Changing pagelabels

Post by Terkelsen »

That works perfect, Jimmy! Thank you (and we all make mistakes from time to time ;) )
User avatar
Terkelsen
Advanced member
Posts: 297
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Re: Changing pagelabels

Post by Terkelsen »

Well, I got the problem solved with a workaround in Switch but that brings me back to the initial problem with the PitStop action, which seems to be a PDF issue.

If I create a simple two page document in InDesign and export that to at PDF having page 1 and 2, the action will not do anything. If I create a similar document in InDesign but with the pages 9 and 10, the action works just fine (labels become 09 and 10).

If I open the PDF with page 1 and 2 in Acrobat, duplicate page 1, make a section start at page 2 but starting with the number 1 (I now have a 3-page PDF with two pages labeled 1 and one page labeled 2) then the action will work fine and relabel all three pages to 01, 01 and 02.

In other words it seems like a PDF only has page label information if a section has been defined?
User avatar
JimmyHartington
Advanced member
Posts: 278
Joined: Tue Mar 22, 2011 7:38 am

Re: Changing pagelabels

Post by JimmyHartington »

Can you send me your test-files? The pdftk utility can dump the data from a pdf. Perhaps I can see something with it.
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: Changing pagelabels

Post by freddyp »

Terkelsen wrote: Wed Mar 29, 2023 3:11 pm If I create a simple two page document in InDesign and export that to at PDF having page 1 and 2, the action will not do anything. If I create a similar document in InDesign but with the pages 9 and 10, the action works just fine (labels become 09 and 10).
...
In other words it seems like a PDF only has page label information if a section has been defined?
A PDF only has page label information if the producer of the PDF adds page label information. What Indesign is doing is to apply the following (understandable) logic: if the document contains consecutive pages from 1 to some number there is no need to add page labels to the PDF because the page labels would be the same as the index numbers. However, if you create an Indesign document starting with page 9 (page i, page A-1, ...) then the logic is: the page numbers are different from the index, let us add those page numbers as labels in the PDF. So, it is not necessarily related to the use of a section, it is enough that the page "names" are different from their indices.

Other producers (Quark, Word, Canva, ...) may handle this differently (I have not checked). Do they support the use of page labels natively? If not, they will probably not add page labels, although theoretically they could. If so, it should be considered a bug if they did not define page labels.

By the way, you have not reacted to my question why you want to use the page labels because using the index in the output name will give you what you want if I understood your initial problem statement correctly.
Last edited by freddyp on Thu Mar 30, 2023 9:17 am, edited 1 time in total.
Reason: Forgot something
User avatar
JimmyHartington
Advanced member
Posts: 278
Joined: Tue Mar 22, 2011 7:38 am

Re: Changing pagelabels

Post by JimmyHartington »

Terkelsen wrote: Wed Mar 29, 2023 3:11 pm In other words it seems like a PDF only has page label information if a section has been defined?
This seems correct.

I used pdftk to dump all data of a file without and with page labels.

Code: Select all

pdftk test-file.pdf dump_data
And as you can see in the output, there is only info about page labels in the file with page labels.

@erik So if you need to sort in Switch maybe you could use pdftk to get this information.

Image
User avatar
Terkelsen
Advanced member
Posts: 297
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Re: Changing pagelabels

Post by Terkelsen »

@Jimmy. Thank you. Thats proves what Freddy just wrote.
@Freddy. Thank you for the explanation. That however, leaves me with another question ;) How is the Split PDF element in Switch then able to ad the page label as a suffix to the file name using [Label], even when the PDF doesn't contain page labels :?:

...and I did actually answer your question in an earlier post:
@Freddy. The reason for using [Label] rather than [Index] is that at a certain time in the process, the PDF doesn't contain all pages. So the PDF for a 56 page magazine may only have 30 of the pages, but they all have the correct page label and the single PDF's need to be named with that page label as a suffix.
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: Changing pagelabels

Post by freddyp »

...and I did actually answer your question in an earlier post:
Sorry, I missed that. That indeed explains the need to use [Label]. It is also logical that page labels do not get leading zeroes because a page label is a string: "First page", "Second page", ..., "Last page" are valid page labels and you can see that adding leading zeroes there does not really make sense.

When there are no page labels then the page label defaults to the index number of the page.
Post Reply