code: def check_page(fn):
          "Decorator to protect drawing methods"
          @wraps(fn)
          def wrapper(self, *args, **kwargs):
              if not self.page and not kwargs.get('split_only'):
                  self.error("No page open, you need to call add_page() first")
              else:
                  return fn(self, *args, **kwargs)
          return wrappef check_page(fn):
          "Decorator to protect drawing methods"
          @wraps(fn)
          def wrapper(self, *args, **kwargs):
              if not self.page and not kwargs.get('split_only'):
                  self.error("No page open, you need to call add_page() first")
              else:
                  return fn(self, *args, **kwargs)
          return wrapper
docs: Decorator to protect drawing methods