pritamps / PDF-Package

Create PDFs from a variety of formats.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PDF Builder

Open Source Love License: MIT Actions Status

Overview

PDF Builder is offer a service for governance applications to generate PDF views of the information generated through independent systems to allow users to have access to printable views of the information.
The key aspects of this PDF Builder are summarized below.

  • PDF Builder is designed to increase the ease of creation of printable PDFs for governance application providers

  • Provides a simple mechanism to map information templates to PDF output designs

  • Supports in facilitating the Digital India vision to develop user centric governance projects

Features

PDF Builder has the following features:

  • Ability to provide a single input request

  • Ability to provide a single custom input request (supplementary feature/block, helper function)

  • Ability to provide a bulk input request

  • Ability to provide a bulk custom input request (custom - supplementary feature, helper function)

  • Ability to review the status of single requests

  • Ability to review the status of bulk requests. Teacher’s were good.

Installation

Installation without Docker

  • Option 1

    • Fork this repo!  
      
  • Option 2

    • Clone this repo to your local machine using  `https://github.com/Samagra-Development/PDF-Package.git`  
      
  • From the root folder run the following command

      $  pip install -r requirements.txt
  • Install postgres and add database detail in src/db/config.py

  • Go to folder src and run following command database table creation:

  • Create a migration repository with the following command:

    $ FLASK_APP=db/app.py flask db init
  • Generate an initial migration:

    $ FLASK_APP=db/app.py flask db migrate     
  • Run migration:

    $ FLASK_APP=db/app.py flask db upgrade 
  • Setup Kafka and add its detail in variable KAFKA_CREDENTIAL in src/pdfbase/config.py.

    • KAFKA_CREDENTIAL config variable detail:
        {
        'topic': 'topicname',  
        'bootstrap_servers': ['moped-01.srvs.cloudkafka.com:9094',  
                              'moped-02.srvs.cloudkafka.com:9094',  
                              'moped-03.srvs.cloudkafka.com:9094'],  
        'security_protocol': 'SASL_SSL',  
        'sasl_mechanism': 'SCRAM-SHA-256',  
        'sasl_plain_username': 'username',  
        'sasl_plain_password': 'password',  
        'group_id': 'form-group',  
        'auto_offset_reset': 'earliest',
        'enable_auto_commit': True,  
        'auto_commit_interval_ms': 1000  
     }
    • Data send to kafka is in byte format convert data from json into byte format using
      value_bytes = bytes(value, encoding='utf-8')
    • E.g of json data
       {'reqd_data':  
       {
       'req_data':{form_data_json},
       generated_data
       }
       }
      form_data_json:
       {'*meta-instance-id*': 'uuid:dc364815-28e9-4735-91fb-587c9e03dc7d',  
      '*meta-model-version*': '7',  
      '*meta-ui-version*': '-',  
      '*meta-submission-date*': '2020-07-13',  
      '*meta-is-complete*': 'True',  
      '*meta-date-marked-as-complete*': '2020-07-13T03:32:26.335Z',  
      'form_intro': '-',  
      'full_name': 'Vikas',  
      'mobile_number': '9588528178',  
      'email_id': 'Kumarv96998@gmail.com',  
      'address_name': 'V. P. O DEVSAR DISTT.& TEH BHIWANI HARYANA - 127021',  
      'objective_name': 'Secure a responsible career opportunity to fully utilize my training and skills',  
      'diploma_education_details_intro': '-',  
      'iti_name': 'Government ITI, Rawaldhi',  
      'iti_trade_name': 'Mechanic Diesel Engine',  
      'check_if_class_twelve': 'no',  
      'class_twelve_details_intro': '-',  
      'class_twelve_school_name': '-',  
      'class_twelve_year': '-',  
      'class_12_stream': '-',  
      'class_twelve_percentage': '-',  
      'class_ten_details_intro': '-',  
      'class_ten_school_name': 'Government Senior Secondary School, Devsar',  
      'class_ten_year': '2014',  
      'class_ten_percentage': '55.2',  
      'experience_details_details_intro': '-',  
      'experience_details_industry_partner': 'Om Diesel Pvt. Ltd.',  
      'training_duration': '3',  
      'achievements_intro': '-',  
      'achievement_1': '1 Computer',  
      'achievement_2': '2 participate in academic Boxing tournament',  
      'skills_intro': '-',  
      'skill_1': '1 Engine service',  
      'skill_2': '2 Kirloskar service',  
      'skil_3': '3 JCB gearbox service',  
      'skill_4': '4 installation',  
      'extra_intro': '-',  
      'extra_curricular_activity_1': '1 SPORTS',  
      'extra_curricular_activity_2': '2 music',  
      'place_filling_form': 'Bhiwani',  
      'candidate_img': 'https://filemanager.gupshup.io/fm/wamedia/demobot1/bb113403-d8bf-4a04-9390-3d51d5bd448c',  
      'submit_intro': 'Ok',  
      'instanceID': 'uuid:dc364815-28e9-4735-91fb-587c9e03dc7d',  
      'calculated_distance': 'Not available'
      }

    generated_data:

    'FORMID': 'resume_questionnaire_v3',   
    'INSTANCEID': 'uuid:dc364815-28e9-4735-91fb-587c9e03dc7d',   
    'USERNAME': '9588528178',   
    'FORMSUBMISSIONDATE': '2020-07-13',   
    'GOOGLE_APPLICATION_CREDENTIALS': 'gcs-creds.json',   
    'BUCKET': 'pdf-builder-samagra',   
    'URL': 'https://script.google.com/macros/s/AKfycbwb1faZ6G7oNikT867oi3C-LbEjEcAYmO-N1UjXByxhs_w48xE/exec?',   
    'DRIVE_DELETE_URL': 'https://script.google.com/macros/s/AKfycbyiH-KvXYFg6L2DJXSiv9TQYkN5AiAn1V1ZLJm6YSEndXQo28EB/exec?',   
    'GOOGLECLOUDBASEURL': 'https://storage.googleapis.com/pdf-builder-samagra/',   
    'MAPPINGDETAILS': 'mappingDetails',   
    'OPTIONSSHEET': 'OptionsSheet',   
    'UPLOADTO': 'google',  
    'ODKUSERNAME': 'samagra',   
    'ODKPASSWORD': 'impact@scale',   
    'SESSIONCOOKIEBASEURL': 'http://aggregate.cttsamagra.xyz:8080/Aggregate.html#submissions/filter///',  
    'DIRPATH': '/../../uploadFiles/',   
    'ACCESSKEY': 'askjfhksjdh',  
    'SECRETKEY': 'skldfhlskdhg',   
    'SHEETID': '14dlQIEo92raBCz26iAzt__duZvdklJr3sgasjdgajjw',  
    'DOCTEMPLATEID': '114TbCy3_QYVGRjGXyj5ac7vrM7Wv75asjgfjasgfkao',   
    'POLRACCESSTOKEN': '41873090067550beb0shdg2871364138e35',  
    'POLRAPIURL': 'http://68.183.94.187/api/v2/action/shorten',   
    'resume_questionnaire_v3': {  
      'APPLICATIONID': '1122',   
      'SHEETID': '14dlQIEo92raBCz26iAzt__duZvdklJr3sgasjdgajjw',   
      'DOCTEMPLATEID': '114TbCy3_QYVGRjGXyj5ac7vrM7Wv75asjgfjasgfkao',   
      'FORMNAME': 'Resume Questionnaire',   
      'GOOGLE_APPLICATION_CREDENTIALS': '../google_doc_plugin/gcs-creds.json',  
      'USERNAMEFIELD': 'mobile_number',   
      'SENDMSG': 'TRUE',   
      'SENDEMAIL': 'TRUE',   
      'MSGFIELD': 'mobile_number',   
      'NAMEFIELD': 'full_name',   
      'EMAILFIELD': 'email_id',   
      'EMAILTEMPLATEID': 4,   
      'DOCDELETED': False  
    },  
    'elem_men_v1': {  
      'APPLICATIONID': '1122',   
      'SHEETID': '1JrxOXyjIla7mN-01dH5aHBPQ6MAOmcGEkawrwerwe1234',   
      'DOCTEMPLATEID': '1Zsi2bj8P8oL0RA7HvqG3gYmTM3596asfsd123324',   
      'FORMNAME': 'ELEMENTARY MENTOR VISIT REPORT',   
      'GOOGLE_APPLICATION_CREDENTIALS': '../google_doc_plugin/gcs-creds.json',  
      'USERNAMEFIELD': 'user_name'  
    },  
    'tags': {'FORMID': 'resume_questionnaire_v3',   
      'USERNAME': '9588528178',   
      'FORMSUBMISSIONDATE': '2020-07-13',   
      'INSTANCEID': 'uuid:dc364815-28e9-4735-91fb-587c9e03dc7d',   
      'FORMNAME': 'Resume Questionnaire'  
    },   
    'instance_id': 'uuid:dc364815-28e9-4735-91fb-587c9e03dc7d',  
    'is_delete': False
  • Setup healthcheckup for pdf generation and add its url in src/pdfbase/config.py in variable HEALTHCHECKURL having key PLUGINURL

  • Setup healthcheck for kafkaconsumer and add its url in src/pdfbase/config.py in variable HEALTHCHECKURL having key KAFKACONSUMERURL

Installation with Docker

  • Setup Kafka and add its detail in variable KAFKA_CREDENTIAL in src/pdfbase/config.py.
  • Go to the project root folder and run following command
    $ docker-compose up --build     

Usage

  • To fetch data from google sheet configure google_doc_plugin configuration using google-doc plugin readme file and then run following command from root folder
    $ python3 -m plugin.google_doc_plugin.server     
  • To fetch data from Form Response configure odk_plugin configuration using [odk plugin readme file](https://github.com/Samagra-Development/PDF-Package/tree/master/src/plugin/odk_plugin and then run following command from root folder
    $ python3 -m plugin.odk_plugin.server    
  • Get data from Kafka by run following command
     $ python3 -m pdfbase.data_consumer    
  • To generate pdf from request, first fetch data from request using above 2 step and then run the following command from root folder
     $ python3 -m pdfbase.main     

API

  • Pdf generated for particular user
  • This api return all the pdf url with status for particular user. You can find api detail in postman collection link

Contribute

To get started...

Step 1

  • Option 1
    • Fork this repo!  
      
  • Option 2
    • Clone this repo to your local machine using
       https://github.com/Samagra-Development/PDF-Package.git  

Step 2

  • From the root folder run the following command
    $ pip install -r requirements.txt 

Step 3

Step 4

  • Go to folder src and run following command database table creation:

    • Create a migration repository with the following command:
       $ FLASK_APP=db/app.py flask db init
    • Generate an initial migration:
      $ FLASK_APP=db/app.py flask db migrate 
    • Run migration:
      $ FLASK_APP=db/app.py flask db upgrade 

License

License

About

Create PDFs from a variety of formats.

License:MIT License


Languages

Language:Python 84.6%Language:JavaScript 9.1%Language:Shell 3.6%Language:Dockerfile 2.3%Language:Mako 0.4%