code: def cmd_export_doc(*args):
      
      (docid, output_pdf, quality, page_format) = _get_export_params(args)
  
      dsearch = get_docsearch()
      doc = dsearch.get(docid)
  
      exporter = doc.build_exporter(file_format="pdf")
      if exporter.can_change_quality:
          exporter.set_quality(quality)
      if exporter.can_select_format:
          exporter.set_page_format(page_format)
      verbose("Exporting {} --> {} ...".format(docid, output_pdf))
      output_pdf = FS.safe(output_pdf)
      exporter.save(output_pdf)
      verbose("Done")
      r = {
          "docid": doc.docid,
          "output_file": output_pdf,
      }
      if exporter.can_change_quality:
          r['quality'] = quality
      if exporter.can_select_format:
          r['page_format'] = page_format
      reply(r)
docs: Arguments:
          <document id> <output PDF file path>
          [-- [--quality <0-100>] [--page_format <page_format>]]
  
      Export one document as a PDF file.
  
      Default quality is 50.
      Default page format is A4.
  
      Possible JSON replies:
          --
          {
              "status": "error", "exception": "yyy",
              "reason": "xxxx", "args": "(xxxx, )"
          }
          --
          {
              "status": "ok",
              "docid": "xxxx",
              "output_file": "file:///tmp/xxxx.pdf",
              "quality": 50,
              "page_format": "A4",
          }