Created
March 6, 2019 08:39
-
-
Save singularitti/633d15ea3a1b3428118f03c44107374a to your computer and use it in GitHub Desktop.
Remove duplicate PDF pages #Python #PDF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# function: remove pause frames of a beamer PDF | |
from pdfrw import PdfReader, PdfWriter | |
def run_stage(src, out): | |
i = PdfReader(src) | |
o = PdfWriter() | |
sum_i = len(i.pages) | |
num_i = i.Root.PageLabels.Nums | |
for r in range(1, len(num_i) // 2): | |
o.addpage(i.pages[int(num_i[r * 2]) - 1]) | |
o.addpage(i.pages[sum_i - 1]) | |
o.write(out) | |
run_stage("__file_name__.pdf", "result.pdf") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment