Versions Compared

Key

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

...

  • 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.

    • 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 :

...

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

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.

...