Skip to content

Instantly share code, notes, and snippets.

@petrbel
Forked from gyfis/pdf_interpolate_false.py
Created May 9, 2017 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petrbel/48c5d5cdb709876b4b23fcf3449700f7 to your computer and use it in GitHub Desktop.
Save petrbel/48c5d5cdb709876b4b23fcf3449700f7 to your computer and use it in GitHub Desktop.
Last frontier destroyed, submitting thesis.pdf
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