import PyPDF2

# with open('dummy.pdf', 'rb') as file:
#     # print(file)
#     reader = PyPDF2.PdfFileReader(file)
#     print(reader.numPages)
#     print(reader.getPage(0))
#     page = reader.getPage(0)
#     page.rotateCounterClockwise(90)      # is now only in memory, not saved
#     writer = PyPDF2.PdfFileWriter()
#     writer.addPage(page)
#     with open('tilt.pdf', 'wb') as new_file:
#         writer.write('new_file')


# PDF Merger Exercise
import sys

inputs = sys.argv[1:]       # grab all the arguments into a lists

def pdf_combiner(pdf_list):
    merger = PyPDF2.PdfFileMerger()
    for pdf in pdf_list:
        print(pdf)
        merger.append(pdf)
    merger.write('super.pdf')

# pdf_combiner(inputs)


# Watermark Exercise
template = PyPDF2.PdfFileReader(open('super.pdf', 'rb'))
watermark = PyPDF2.PdfFileReader(open('wtr.pdf', 'rb'))

output = PyPDF2.PdfFileWriter()

for i in range(template.getNumPages()):
    page = template.getPage(i)
    page.mergePage(watermark.getPage(0))
    output.addPage(page)
    with open('watermarked.pdf','wb') as file:
        output.write(file)

63efebe0e142c4ca42206aa42441ca42f51cd2aa
<mask token>


def pdf_combiner(pdf_list):
    merger = PyPDF2.PdfFileMerger()
    for pdf in pdf_list:
        print(pdf)
        merger.append(pdf)
    merger.write('super.pdf')


<mask token>

<mask token>


def pdf_combiner(pdf_list):
    merger = PyPDF2.PdfFileMerger()
    for pdf in pdf_list:
        print(pdf)
        merger.append(pdf)
    merger.write('super.pdf')


<mask token>
for i in range(template.getNumPages()):
    page = template.getPage(i)
    page.mergePage(watermark.getPage(0))
    output.addPage(page)
    with open('watermarked.pdf', 'wb') as file:
        output.write(file)

<mask token>
inputs = sys.argv[1:]


def pdf_combiner(pdf_list):
    merger = PyPDF2.PdfFileMerger()
    for pdf in pdf_list:
        print(pdf)
        merger.append(pdf)
    merger.write('super.pdf')


template = PyPDF2.PdfFileReader(open('super.pdf', 'rb'))
watermark = PyPDF2.PdfFileReader(open('wtr.pdf', 'rb'))
output = PyPDF2.PdfFileWriter()
for i in range(template.getNumPages()):
    page = template.getPage(i)
    page.mergePage(watermark.getPage(0))
    output.addPage(page)
    with open('watermarked.pdf', 'wb') as file:
        output.write(file)

import PyPDF2
import sys
inputs = sys.argv[1:]


def pdf_combiner(pdf_list):
    merger = PyPDF2.PdfFileMerger()
    for pdf in pdf_list:
        print(pdf)
        merger.append(pdf)
    merger.write('super.pdf')


template = PyPDF2.PdfFileReader(open('super.pdf', 'rb'))
watermark = PyPDF2.PdfFileReader(open('wtr.pdf', 'rb'))
output = PyPDF2.PdfFileWriter()
for i in range(template.getNumPages()):
    page = template.getPage(i)
    page.mergePage(watermark.getPage(0))
    output.addPage(page)
    with open('watermarked.pdf', 'wb') as file:
        output.write(file)

import PyPDF2

# with open('dummy.pdf', 'rb') as file:
#     # print(file)
#     reader = PyPDF2.PdfFileReader(file)
#     print(reader.numPages)
#     print(reader.getPage(0))
#     page = reader.getPage(0)
#     page.rotateCounterClockwise(90)      # is now only in memory, not saved
#     writer = PyPDF2.PdfFileWriter()
#     writer.addPage(page)
#     with open('tilt.pdf', 'wb') as new_file:
#         writer.write('new_file')


# PDF Merger Exercise
import sys

inputs = sys.argv[1:]       # grab all the arguments into a lists

def pdf_combiner(pdf_list):
    merger = PyPDF2.PdfFileMerger()
    for pdf in pdf_list:
        print(pdf)
        merger.append(pdf)
    merger.write('super.pdf')

# pdf_combiner(inputs)


# Watermark Exercise
template = PyPDF2.PdfFileReader(open('super.pdf', 'rb'))
watermark = PyPDF2.PdfFileReader(open('wtr.pdf', 'rb'))

output = PyPDF2.PdfFileWriter()

for i in range(template.getNumPages()):
    page = template.getPage(i)
    page.mergePage(watermark.getPage(0))
    output.addPage(page)
    with open('watermarked.pdf','wb') as file:
        output.write(file)
