Skip to content

InnoSWP/05-DocPdf-Converter

Repository files navigation

Doc to PDF converter

Badges

Linter

Build

Unit tests Django

Django CI

Sonar cloud

Quality Gate Status Lines of Code Coverage Bugs Vulnerabilities Maintainability Rating Security Rating Reliability Rating Technical Debt Code Smells

Project Description

This is the project with user-friendly and simple interface that perform converting files with .doc/.docx extention to PDF on local Windows/Linux server

  • Each of the algorithms (both for Windows and Linux) uses the built-in functions of programs-viewers (such as Microsoft Word for Windows and LibreOffice Writer for Linux) to convert files with .doc/.docx extension to PDFs with minimum errors of conversion.
  • All files after the conversion are returned in archive with PDFs (if there are more than one file) or as a single PDF file otherwise.
  • In case if the user will choose file(-s) with ".pdf" extension, then the program will send them back =).

Project Demo

Main processes

Demo.mp4

Errors

  1. Attempt to convert nothing
  2. Attempt to convert file(-s) with unsupported extensions
errs.mp4

Project Installation

  1. Clone the project
  2. Open project directory in console
  3. Make the scripts' executables:

chmod +x runserver.sh build.sh first-run.sh

To run project first time with bash script (with installing dependencies)

source ./first-run.sh

To install dependencies with bash script

source ./build.sh

To run server without installing dependencies

source ./runserver.sh

To set up the project, set your virtual env using the commands in this order (Ubuntu)

  1. sudo apt install python3
  2. sudo apt install python3-venv
  3. sudo -S apt -y update && sudo -S apt -y install libreoffice
  4. python3 -m venv venv
  5. source venv/bin/activate
  6. pip install -r requirements.txt
  7. python3 manage.py makemigrations
  8. python3 manage.py makemigrations main
  9. python3 manage.py migrate
  10. python3 manage.py migrate One command format: sudo apt install python3 && sudo apt install python3-venv && sudo -S apt -y update && sudo -S apt -y install libreoffice && python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt && python3 manage.py makemigrations && python3 manage.py makemigrations main && python3 manage.py migrate && python3 manage.py runserver

To set up the project, set your virtual env using the commands in this order (Bash)

  1. source venv/Scripts/activate
  2. python manage.py makemigrations
  3. python manage.py makemigrations main
  4. python manage.py migrate
  5. python manage.py runserver

You can also add server runner to your configs. To that, follow this steps (PyCharm)

  1. Open configurations editor
  2. Add new configuration
  3. Python
  4. Name it as you want
  5. Set script path (Path to manage.py)
  6. Set parameters: "runserver"
  7. Make sure that here is configured your environment

After running the local server

  1. Go on the generated link.
  2. The main page will be opened. There you will see two buttons: "Choose files" and "Convert".
  3. You can choose files on your machine and after that convert them by clicking the same-called buttons.
  4. Depending on the amount of chosen files, you will receive a single-converted file (if you chose one file) or an archive of converted files otherwise.

Framework and technology

Frontend

  • HTML
  • CSS
  • JavaScript
  • JQuery

Backend

  • Python
    • Django
    • Django Rest Framework
    • Sphinx
    • docx2pdf

Features

Cross-platform

DocPdf converter has two different modules that allow efficient conversion on both Linux and Windows-based servers. The system identifies the platform it runs on, and, depending on the result, executes corresponding module.

Description of requests

Please, pay attention to the fact the under correct file(s) in Body param name we assume all the files with the correct extension:

  • .doc
  • .docx
  • .xls
  • .xlsx
  • .PDF

To see example requests on Postman, you should firstly accept the invitation

URL Request type Body param name Param value Response code Response content Example
http://127.0.0.1:8000/convert POST files single correct file 200 single .pdf file Postman
http://127.0.0.1:8000/convert POST files multiple correct files 200 multiple .pdf file Postman
http://127.0.0.1:8000/convert POST files null 400 { "error": "invalid_files", "error_description": "Files field is empty."} Postman
http://127.0.0.1:8000/convert POST files empty file 400 { "error": "empty_file", "error_description": "Empty file in your request."} Postman

About

Simple API that converts documents to PDF for corporate portal

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published