3

PDF files of slide show presentations distributed by my lecturers often contain a huge number of pages, because each animation step results in an new page (sometimes 20 pages per slide).

This is nice if one wants to view the slide show on a screen. But I would like to print the slides and in order to save paper I would prefer to only print the complete slides (after all animation steps took place).

The structure of these PDFs is as follows:

Page: 1/12, slide: 1
Page: 2/12, slide: 1
Page: 3/12, slide: 1 -> complete first slide (this is what I want to print)
Page: 4/12, slide: 2
...

I noticed that evince actually keeps track about which slide we are on. It displays the slide number next to the actual page number (as above). So apparently the slide numbers are saved in the PDF file and it should be possible to identify which one is the last page of one slide and print only that one.

So my question is: Is there a way to extract the last page of each slide (the last page which uses the same slide number) using tools like pdftk or GS or similar?

Note: I think that this problem must be quite common, but I could not find any similar posts. I apologize if this is a duplicate.

2
  • That might depend on how the slides were generated. Can you share a sample file? Commented May 18, 2015 at 20:18
  • 1
    Here's an example file, 3 logical pages, 5 physical pages: link to overleaf source To download the PDF click the PDF button in the top centre.
    – Marco
    Commented May 19, 2015 at 7:19

1 Answer 1

1

Here is a script to do so which works on the example in Marco's comment. It makes use of pdftk.

#!/bin/sh
PAGES=$(pdftk $1 dump_data |                      
    grep PageLabelNewIndex |
    cut -d' ' -f2 |                                                         
    xargs -n1 expr -1 + |                                                   
    tail -n+2 |                                                             
    tr '\n' ' ');                                                           
# Add last page                                                                 
PAGES="${PAGES} $(pdftk $1 dump_data |                                          
    grep NumberOfPages |                                                    
    cut -d' ' -f2)";                                                        

pdftk $1 cat ${PAGES} output $2

Give the input file as the first parameter, and an output filename as the second parameter.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .