code: def setMetadata(doc, m):
      
      if doc.isClosed or doc.isEncrypted:
          raise ValueError("operation on closed or encrypted document")
      if type(m) is not dict:
          raise ValueError("arg2 must be a dictionary")
      for k in m.keys():
          if not k in ("author", "producer", "creator", "title", "format",
                       "encryption", "creationDate", "modDate", "subject",
                       "keywords"):
              raise ValueError("invalid dictionary key: " + k)
      d = "<</Author"
      d += getPDFstr(m.get("author", "none"))
      d += "/CreationDate"
      d += getPDFstr(m.get("creationDate", "none"))
      d += "/Creator"
      d += getPDFstr(m.get("creator", "none"))
      d += "/Keywords"
      d += getPDFstr(m.get("keywords", "none"))
      d += "/ModDate"
      d += getPDFstr(m.get("modDate", "none"))
      d += "/Producer"
      d += getPDFstr(m.get("producer", "none"))
      d += "/Subject"
      d += getPDFstr(m.get("subject", "none"))
      d += "/Title"
      d += getPDFstr(m.get("title", "none"))
      d += ">>"
      doc._setMetadata(d)
      doc.initData()
      return
docs: Set a PDF's metadata (/Info dictionary)\nm: dictionary like doc.metadata'.