Skip to content

Abhishek-kumar82078/docx-converter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docx_Converter

A full-stack website application to convert a word document into either pdf, XML, or text format.

Tech stack : HTML5, CSS3, JavaScript, FastApi, Python, AJAX, jQuery

Some highlighted features of this application:-

  • Take a word document and the required format as input.
  • Convert that file into the required format among any of the three formats XML, text, or pdf.
  • Return the converted file with the same name as that of the input which can be viewed as well as downloaded
  • Releases log messages for every action it starts performing. Hence easy to debug and fix the error when generated.

This application also make use of 3 modules:-

This project can be used in two ways.

A. Use the UI to convert your file.

B. Use the backend code either to convert your file or use the API to implement your own project.

1. Follow the below steps to use the UI to convert your file:-

  • Step 1 : Select the docx file by clicking on the button or drag and drop the file
image
  • Step 2 : Choose the required format from XML, pdf, or txt by clicking on their respective image. When it will be selected there will be a dark purple background signifying that the format has been chosen. Since those are radio buttons only one will be selected at a time.
image
  • Step 3 : Click on the convert button and it will start converting your file landing you on the loading page.
image
Your task is now finished. Simply relax as your file will be converted in just a fraction of a second.
  • Step 4 : You will be taken to a different page where you can view your converted file.
image
  • Step 5 : Finally, you can download your converted file by clicking on the download button.
image

Its backend part can be utilized independently as a API and imported into your project as needed.

Get the code here .

Backend part has been implemented using FastAPI. FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.

2. Follow the below steps to use the backend code to convert your file:

  • Create a virtual environment after deciding a directory where you want to place it, and run the venv module as a script with the directory path:
      python3 -m venv local-env
  • Once you’ve created a virtual environment, follow below command on Windows to activate it as
      local-env/scripts/activate

Or on Unix or MacOS.

      source local-env/bin/activate
  • Installs all of the modules listed in my Python requirements file into your project environment using
pip install -r requirements.txt
  • Make a small changes in the main.py file present inside backend directory. Replace
 return {"Destination File Path": dest_file} 

with

return {"Destination File Path": f"{SERVER_ADDRESS}/output_files/{dest_file}"} 
  • Navigate to the backend directory and then run your application using the below command:
uvicorn main:app --reload
  • You can now go to the below URL and try uploading the file and format
http://127.0.0.1:8000/docs
  • Click on "Try it out" in top right corner as shown in the image.

image

  • Now choose the file by clicking on "Choose File" input, enter the required format, and click on the "Execute" button.

image

  • As soon as you click on the "Execute" button, the program will start its execution and return you a destination file path as the response.

image

  • Go to the URL provided in the response body as above and you will get your converted file. Url is like:
127.0.0.1:8000/output_files/sample05082022_212849.pdf

Finally, your file has been converted.

Cheers!

About

Convert Word Documents to PDF / XML / TXT

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CSS 39.5%
  • Python 23.0%
  • JavaScript 20.3%
  • HTML 17.0%
  • Procfile 0.2%