Created
May 9, 2017 14:48
-
-
Save gyfis/cbced399bc072d937c92b89d3b9cffa0 to your computer and use it in GitHub Desktop.
Last frontier destroyed, submitting thesis.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
from pdfrw import PdfReader, PdfWriter, PdfObject | |
def main(): | |
thesis = PdfReader('thesis.pdf') | |
for i, _ in enumerate(thesis.pages): | |
try: | |
im_keys = thesis.pages[i].Resources.XObject.keys() | |
for key in im_keys: | |
thesis.pages[i].Resources.XObject[key].Interpolate = PdfObject('false') | |
thesis.pages[i].Resources.XObject[key].SMask.Interpolate = PdfObject('false') | |
except: | |
print('This page does not have images: {}'.format(i)) | |
PdfWriter().write('thesis_out.pdf', thesis) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment