yeyeto2788 / OpenNoteScannerPDF

PDF creator for OpenNoteScanner Android App

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenNoteScanner PDF Creator:

Master build status made-with-python

This repository contains some Python scripts that will let you create a final .pdf file to use with the Android Application OpenNoteScanner.

You can create the file by web API or by a single script. You go to PythonAnywhere and you'll see the web application running and get you .pdf file from it.



Quick explanation of the code:

Main PDF Generator script

With a given QR data, .pdf file name and a maximum amount of pages, it will create QR images of 512x512 Pixels with the QR data given plus a number ant the end of the data.

Once the QR images are generated the background images are created, these Background images are generated as:

  • 1 main background (white)
  • 1 middle image (black)
  • 1 top image (white).

Those images are pasted together to have a final image with a "Black Border" with an A4 or letter size with a resolution of 300dpi.

Once all images are done, it will iterate over each QR image generated previously creating each page of the .pdf placing the QR images on the right bottom site of the page.

If you want more deep information please have a look at the auto generated documentation here.

Server application script

This server application is developed with Flask framework and it just have only 1 landing page (index.html) with some information about how to use the API and some other info.

API server script

The API is pretty straight forward, it only have one endpoint which is in /api/<page_size>/<qr_data>/<int_pages> so an example will be something like /api/A4/P01_V05_S/50 and the API will return a .pdf file generated using the main pdf generator script with the following information:

  • PDF size = A4
  • QR data = Images from P01_V05_S-0000000 to P01_V05_S-0000050
  • Number of pages = 50

How to run the code through CLI in Linux:

  1. Let's update our system:

    sudo apt-get update
    sudo apt-get upgrade
    
  2. Let's install the modules needed:

    We actually need some modules but some of them depend on other modules so for this I have upload a file called requirement.txt which has all packages installed on my computer but you don't need all this modules on you computer, so you have two options to install the packages.

    • Option 1:
    sudo pip install Pillow
    sudo pip install reportlab
    sudo pip install qrcode
    
    • Option 2:
    sudo pip install -r requirement.txt
    
  3. Let's test the code and the modules

    let's go to the Test directory and let's execute one of the files. Execute this on the terminal: python Multiple_QRcodes.py or python Single_QRcode.py

  4. We are ready to run the script and get the PDF file

    Run the code by typing on the terminal the following command: python generate_single_pdf.py or sudo python generate_single_pdf.py This will generate the .pdf file on the PDF directory and the final images used on the .pdf file in the QR directory.

How to run the code for the server in Linux:

  1. Follow steps for CLI operations first to that code is working properly

  2. So now let's just run the server

    Run the server by the following command: python run_server.py or sudo python run_server.py

    Now we can open up a browser tab or window and go to the 127.0.0.1:800/api/<page_size>/<qr_data>/<int_pages> where:

    • page_size = Should be either A4 or letter

      If not the application will return the message Please check size.

    • qr_data = The data you want to have on the QR image

      You have to have a data length higher than 4 character because if you do not do it you'll get the error QR data length should be higher than 4.

    • int_pages = Integer with the numbers of the pages you want the .pdf file to have.

    This will be pages of the server:

    Image of the pdf embbeded on the browser Image of the pdf embbeded on the browser
  3. Print it!

    If you followed the steps above you should have gotten the pdf file on the browser like this:

    Image of the server with index page Image of the server with documentation page

    now you just have to print it.

Note: If you want the server running on the background just and an ampersand (&) at the end of the command when you execute the server.

Final PDF example

If you did it correctly you should get a .pdf file like this:

Image of the pdf file

In this link you can see the final .pdf file created.

Android Application

Google Play link

GitHub Repository

Some useful links:

Reporlab Module.

QRcode Module.

Pillow Module.

@BlackrockDigital BootStrap template.

Modules Documentation:

Pillow Documentation.

Reportlab Documentation.

QRcode Documentation.

About

PDF creator for OpenNoteScanner Android App


Languages

Language:Python 64.5%Language:HTML 32.9%Language:JavaScript 1.9%Language:CSS 0.7%