docs: def rotate(file_name, rotate, suffix='rotated', tempdir=None):
      """Rotate PDF by increments of 90 degrees."""
      # Set output file name
      if tempdir:
          outfn = NamedTemporaryFile(suffix='.pdf', dir=tempdir, delete=False).name
      elif suffix:
          outfn = os.path.join(os.path.dirname(file_name), add_suffix(file_name, suffix))
      else:
          outfn = NamedTemporaryFile(suffix='.pdf').name
  
      trailer = PdfReader(file_name)
      pages = trailer.pages
  
      ranges = [[1, len(pages)]]
  
      for onerange in ranges:
          onerange = (onerange + onerange[-1:])[:2]
          for pagenum in range(onerange[0] - 1, onerange[1]):
              pages[pagenum].Rotate = (int(pages[pagenum].inheritable.Rotate or 0) + rotate) % 360
  
      outdata = PdfWriter(outfn)
      outdata.trailer = trailer
      outdata.write()
      return outfn