docs: def save(self, *args, **kwargs):
          """Customized to generate an image from the pdf file."""
          # open image from pdf
          img = Image(filename=self.file.path + '[0]')
  
          # make new filename
          filename = os.path.basename(self.file.path).split('.')[:-1]
          if type(filename) == list:
              filename = ''.join(filename)
  
          # TODO: Would be better to compute this path from the upload_to
          # setting which is already set on the model field
          image_dir = os.path.join(
              django_settings.MEDIA_ROOT, UPLOAD_TO_DIR)
          if not os.path.exists(image_dir):
              os.makedirs(image_dir)
  
          image_path = os.path.join(
              image_dir, '{}.jpg'.format(filename))
          tmp_image_path = os.path.join(
              image_dir, '{}.tmp.jpg'.format(filename))
  
          # we remove the old image befor we save because the cover might have
          # changed when we upload a new PDF file - even when that file has the
          # same filename as the old one
          try:
              os.remove(image_path)
          except OSError:
              # file is already gone
              pass
          # and we also remove the thumbnails
          old_files = glob.glob('{}.*'.format(image_path))
          for old_file in old_files:
              try:
                  os.remove(old_file)
              except OSError:
                  pass
  
          # save as image under a temporary filename so that we can read it with
          # File()
          img.save(filename=tmp_image_path)
          # attach it to image field
          with open(tmp_image_path, 'r') as f:
              self.image.save('{}.jpg'.format(filename), File(f), save=False)
          super(PDFPluginModel, self).save(*args, **kwargs)
  
          # remove temp file
          try:
              os.remove(tmp_image_path)
          except OSError:
              pass