Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
 {
  “Variable”: “variable_name”,
  “Value”:{
    “path”: “$.propertyId”             -----> jsonpath to obtain value or key to obtain value from localisation.
  },
  “type”:  “label”,                    -----> this field is used to mark this variable as label.       
  “localisation”:{
      “required”: “false”,             -----> if this field is true then  localisation is used for this variable and vice versa.
      “prefix”: “null”,                -----> prefix of the key which is declared in path field.
      “module”: “rainmaker-tl”         -----> the module from which localisation entry is fetched
  }
}

Example of external API calling to MDMS serviceto show date in PDF

Code Block
“externalAPI”: [{
  “Variable”: “variable_name”,
  “Value”:{
    “path”: “http://egov-mdms-service:8080/egov-mdms-service/v1/_get”,
    “queryParam”: “moduleName=tenant&masterName=tenants&tenantId=pb&filter=%5B?(@.code=='{$.tenantId}')%5D”,
    “apiRequest”: null,
    “responseMapping”:[
      {
          “variable”: “address”,
          “value”: “$.MdmsRes.tenant.tenants[0].address”
      },
       “$.date”             -----> jsonpath to obtain epoch value of date
  },
  “type”:  “label”,                    -----> this field is used to mark this variable as date.       
  "format": "YYYY MM DD "
}

If the format field in not specified in date variable declaration then in PDF date is shown with default format of DD MM YYYY. For more details refer this page Unix-Timestamp

Example of external API calling to MDMS service

Code Block
“externalAPI”: [
    “path”: “http://egov-mdms-service:8080/egov-mdms-service/v1/_get”,
    “queryParam”: “moduleName=tenant&masterName=tenants&tenantId=pb&filter=%5B?(@.code=='{$.tenantId}')%5D”,
    “apiRequest”: null,
    “responseMapping”:[
      {
          “variable”: “phoneNumber”“address”,
          “value”: “$.MdmsRes.tenant.tenants[0].contactNumber”address”
      },
    ]  {
          ]

The format config file contain the following aspect :

...

“variable”: “phoneNumber”,
          “value”: “$.MdmsRes.tenant.tenants[0].contactNumber”
      }
    ]
  ]

The format config file contain the following aspect :

  • key: The key for the pdf, it is used as a path parameter in URL to identify for which PDF has to  generate.

  • Content: In this section, the view of pdf is set. What has to be appear on pdf is declared here, it  just like creating a static html page. The variable which are defined in data config are declared here and place in position as per the requirement. We can also create table here and set the variable as per requirement. 

  • Style: This section is used to style the component, set the alignment and many more. Basically it's like a CSS to style the html page.

Example of adding footer in PDF (adding page number in footer)

Code Block
{
"key": "property-bill",
"config": {
"defaultStyle": {....},
"content": [....],
"style": {....},
"footer": "(function(currentPage, pageCount) { return currentPage.toString() + ' of ' + pageCount; })"
}
}

...

The position of page number in footer is configurable. For more detail refer this document Header and Footer

API Call :

_create :

This API request to PDF generation service is made to generate pdf and return the filestore id and job id.

...