# new UBServerReport (reportCodestring | Object, reportTypeoptstring, paramsObject, languageoptString)

Arguments:
  • reportCode: string| Object

    If reportCode type is Object it is a config object { code: String, type: String, params: String|Object }

  • reportType = 'html': string

    Possible values: 'html'|'pdf'

  • params: Object
  • language = Session.userLang: String

Members

# incomeParams instance

Report parameters

Name Type Description
incomeParams Object

# reportCode instance

Report code

Name Type Description
reportCode string

# reportOptions instance

The options of report. Known options: pageOrientation.

Name Type Description
reportOptions Object

# reportType instance

Possible values: 'html', 'pdf'

Name Type Description
reportCode string

Methods

# buildHTML (reportDataObject) → string instance

Render HTML report

Arguments:

# buildReport (reportParamsObject) → Promise | Object | String instance

This function must be defined in report code block.

Inside function you must:

  • Prepare data
  • Run method this.buildHTML(reportData); where reportData is data for mustache template
  • If need create PDF run method this.buildPdf(htmlReport); where htmlReport is HTML
  • If is server side function must return report as string otherwise Promise

Return:

If code run at server, method must return report data, else - Promise, which resolves to report data

Arguments:

# getDocument (attributestring) → string instance

load document

Arguments:

# init () instance

Load report template and code.

# makeReport (paramsoptObject) → ReportResult instance

Render report on server

Arguments:
  
      const UBReport = require('@unitybase/ubs/modules/UBServerReport')
let reportResult = UBReport.makeReport('reportCode', 'html', {
  login: email,
  password: password,
  activateUrl: registrationAddress,
  appConfig: App.serverConfig
})
  

# transformToPdf (htmlstring, optionsObject) → Promise instance

Prepare PDF report from html

Return:

A promise that resolves with an ArrayBuffer with PDF or instance of PDF.csPrintToPdf with rendered HTML on it when options.outputPdf is false.

Arguments:
  • html: string
  • options: Object
    • fontsArray | Object

      [{ fontName: "TimesNewRoman", fontStyle: "Normal" }, ..]

    • outputPdfBoolean

      If it is not False build PDF output at end. By default it is True.