File: metadata.py

package info (click to toggle)
pdfrw 0%2Bsvn136-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 208 kB
  • sloc: python: 1,761; makefile: 2
file content (39 lines) | stat: -rwxr-xr-x 783 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python

'''
usage:   metadata.py <first.pdf> [<next.pdf> ...]

Creates output.pdf

This file demonstrates two features:

1) Concatenating multiple input PDFs.

2) adding metadata to the PDF.

If you do not need to add metadata, look at subset.py, which
has a simpler interface to PdfWriter.

'''

import sys
import os

import find_pdfrw
from pdfrw import PdfReader, PdfWriter, IndirectPdfDict

inputs = sys.argv[1:]
assert inputs
outfn = 'output.pdf'

writer = PdfWriter()
for inpfn in inputs:
    writer.addpages(PdfReader(inpfn, decompress=False).pages)

writer.trailer.Info = IndirectPdfDict(
    Title = 'your title goes here',
    Author = 'your name goes here',
    Subject = 'what is it all about?',
    Creator = 'some script goes here',
)
writer.write(outfn)