Versions Compared

Key

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

...

Step 3:  The file which are created earlier, their absolute path has to mention in dev.yml which is present inhttps://github.com/egovernments/eGov-infraOps/blob/master/cluster/conf/dev.yml in dev.yaml and qa.yaml Before editing the file create another branch and edit the dev.yaml file and qa.yml yaml file , mentioned proper file path like

...

After editing the file, raise the pull request to DevOPS, so they can merge the branch to master.

Step 4: Before running starting the PDF generation service, persister and filestore service has to be running. First make sure that  pdf-generator.yml persister file is present in  https://github.com/egovernments/configs/tree/master/egov-persister If not present then add the file and raise the pull request to Devops. Run the Persister service present in the link given below:  https://github.com/egovernments/core-services/tree/master/egov-persisterRun the Filestore service present in the link : https://github.com/egovernments/core-services/tree/master/egov-filestore

...

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

  • baseKeyPath: The json path for the array object that we need to process. 

  • entityIdPath: The json path for the unique field which is stored in DB. And that unique field value is mapped to file-store id, so we can directly search the pdf which was created earlier with the unique field value and there will be no need to create PDF again.

  • mapping: There are three mapping object for variable which are direct mapping, externalApi mapping and derived mapping.

    • Direct Mapping: In direction mapping we define the variable whose value can be fetched from the array object which we extracted using baseKeyPath.

    • ExternalApi Mapping: We use the externalApi mapping only if there is a need of values from other service response. In externalApi mapping, API endpoint has to be set properly with correct query parameter.

    • Derived mapping: In derived mapping, the estimation of variable characterize here is equivalent to esteem which acquired from the arithmetic operation between variable of direct mapping and externalApi mapping.

Sample structure of variable definition in data config :

...

    • QRCode mapping: This mapping is used to draw QR codes in the PDFs. The text to be shown after scan can be combination of static text and variables from direct and externalApi mappings.

Sample structure of variable definition in data config :

Code Block
{
  “Variable”: “variable_name”,
  “Value”:{
      “path”: “$.propertyId”             -----> jsonpath to obtain value.
  }

}

...

Code Block
{
  “Variable”: “variable_name”,
  “Value”:{
    “path”: “$.date”             -----> jsonpath to obtain epoch value of date
  },
  “type”:  “label”,   "date"                  -----> this field is used to mark this variable as date.       
  "format": "YYYY/MM/DD "
}

...

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

API Call :

_create :

...

QRCode: For adding QRcode there is separate mapping with the name “qrcodeConfig“ in data config. This mapping can use variables defined in “direct” and “external“ mappings along with static text. The information on QR Code scan will be defined as value. The variable defined in this mapping can directly be used in format config as image. ex:-

DataConfig for QRCode:

Code Block
"mappings": [
          {
            "direct": [
              {
                "variable": "propertyID",
                "value": {
                  "path": "$.consumerCode"
                }
              },
              {
                "variable": "tenantId",
                "value": {
                  "path": "$.tenantId"
                }
              },
              {
                "variable": "businessServiceCode",
                "value": {
                  "path": "$.businessService"
                }
              }
            ]
          },
          {
            "qrcodeConfig": [
              {
                "variable": "qrcodeimage",
                "value": "citizen/egov-common/pay?consumerCode={{propertyID}}&tenantId={{tenantId}}&businessService={{businessServiceCode}}"
              }
            ]
          }
        ]

Format Config for QRCode

Code Block
{
  "image": "{{qrcodeimage}}", ----> use declared variable in qrcodeConfig from dataconfig
  "width": 64,
  "height": 64
}

QRcode pdf example:-

In property bill QR code is displayed

dataconfig:- https://github.com/egovernments/configs/blob/master/pdf-service/data-config/property-bill.json

formatconfig:- https://github.com/egovernments/configs/blob/master/pdf-service/format-config/property-bill.json

API Call :

_create :

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

...

https://egov-micro-dev.egovernments.org/pdf-service/v1/_search?entityid=BILL-000676

Postman collection

https://www.getpostman.com/collections/5a9bfd6fd03f9f2a6fad

Steps for running PDF Generation Service locally

...