Beispiel #1
0
  def create_report(self):
    from report.report import Report
    import json

    if len(self.params)>0:
      params = json.loads(self.params[0])

    if not "orientation" in params:
      params["orientation"] = "p"
    if not "size" in params:
      params["size"] = "a4"
    if not "output" in params:
      params["output"] = "pdf"
    rpt = Report(orientation=params["orientation"],format=params["size"])

    if "data" in params:
      rpt.databind = params["data"]
    if "template" in params:
      rpt.loadDefinition(params["template"])
    rpt.createReport()
    if params["output"] == "pdf":
      import binascii
      sys.stdout.write(binascii.b2a_base64(rpt.save2Pdf()))
    elif output == "xml":
      sys.stdout.write(rpt.save2Xml())
    else:
      sys.stdout.write(rpt.save2Html())
Beispiel #2
0
  def load_report_xml(self):
    from report.report import Report
    
    orient = "p"
    if len(self.params)>0:
      orient = self.params[0]
    output = "pdf"  
    if len(self.params)>1:
      output = self.params[1]
    deffile = self.params[2]

    rpt = Report(orient)
    xdata = self.read_file(deffile)
    rpt.loadDefinition(xdata)
    rpt.createReport()
    if output == "pdf":
      import binascii
      sys.stdout.write(binascii.b2a_base64(rpt.save2Pdf()))
    elif output == "xml":
      sys.stdout.write(rpt.save2Xml())
    else:
      sys.stdout.write(rpt.save2Html())