Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Converter App using python #709

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions BasicPythonScripts/Document Converter App/README.MD
@@ -0,0 +1,79 @@
## Document converter using python

- This is a script which is used for converting files from one extension to other (for example, to convert from jpg to pdf, pdf to word etc).

### About the Script

It takes 3 parameters as input:

- path where the file to be converted, is stored(source_path).
- path where the converted file has to be saved(destination_path).
- the name by which the converted file has to be saved.
(for example, if we are converting "test.jpg" to "test.pdf", the program takes the path where "test.jpg" is stored,then path where "test.pdf" has to be saved along with the name by which it should be saved(test)).

### Setup instructions

1. Install Python 3.x (recommended) from `<a href="https://www.python.org/downloads/">`here `</a>`
2. Download this repository as zip and extract.
3. Use Python IDLE or PyCharm to run the program.
4. Run the code and start taking input as Row and Column.`<br>`
5. Have fun!!

### Output Screenshots

**Excel to Pdf**

- [Code for conversion](excel_to_pdf.py)

![excel_to_pdf](Images/excel_to_pdf.png)

**Jpg to Pdf**

- [Code for conversion](jpg_to_pdf.py)

![jpg_to_pdf](Images/jpg_to_pdf.png)

**Jpg to Png**

- [Code for conversion](jpg_to_png.py)

![jpg_to_png](Images/jpg_to_png.png)

**Pdf to Jpg**

- [Code for conversion](pdf_to_jpg.py)

![pdf_to_jpg](Images/pdf_to_jpg.png)

**Pdf to Png**

- [Code for conversion](pdf_to_png.py)

![pdf_to_png](Images/pdf_to_png.png)

**Pdf to Pptx**

Execute the following command in the terminal:

```
pdf2pptx pdf_path.pdf
```
- (Replace pdf_path by your file path)


![pdf_to_pptx](Images/pdf_to_pptx.png)

**Ppt to Pdf**

Execute the following command in the terminal:

```
ppt2pdf file ppt_path.pptx
```
- (Replace ppt_path by your file-path)

![ppt_to_pdf](Images/ppt_to_pdf.png)

### Author

[Damarla Venkata Sai Chandana](https://github.com/chandu6111)
18 changes: 18 additions & 0 deletions BasicPythonScripts/Document Converter App/excel_to_pdf.py
@@ -0,0 +1,18 @@
# This script converts excel files to pdf files

# Import Module
from win32com import client

# Open Microsoft Excel
excel = client.Dispatch("Excel.Application")

excel_path = input("Enter the path of the excel file completely: ")
pdf_path = input(
"Enter the path of the folder where you want pdf file to be present: ")
pdf_name = input("Enter the name by which pdf file should be saved: ")
# Read Excel File
sheets = excel.Workbooks.Open(excel_path)
work_sheets = sheets.Worksheets[0]

# Convert into PDF File
work_sheets.ExportAsFixedFormat(0, pdf_path+'\ '+pdf_name+".pdf")
17 changes: 17 additions & 0 deletions BasicPythonScripts/Document Converter App/jpg_to_pdf.py
@@ -0,0 +1,17 @@
# import image from pillow module
from PIL import Image

# user input of the jpg image path
jpg_path = input("Enter the path of the .jpg image : ")

# opening jpg image
im1 = Image.open(jpg_path)

# user input of pdf file path
pdf_path = input("Enter the folder where pdf file should be saved : ")

# user input of pdf file name to be saved
pdf_name=input("Enter the name by which the pdf file should be saved: ")

# saving as png image
im1.save(pdf_path+"\ "+pdf_name+".pdf")
17 changes: 17 additions & 0 deletions BasicPythonScripts/Document Converter App/jpg_to_png.py
@@ -0,0 +1,17 @@
# import image from pillow module
from PIL import Image

# user input of the jpg image path
jpg_path = input("Enter the path of the .jpg image : ")

# opening jpg image
im1 = Image.open(jpg_path)

# user input of png image path
png_path = input("Enter the folder where .png image should be saved : ")

# user input of png file name to be saved
png_name=input("Enter the name by which the .png image should be saved: ")

# saving as png image
im1.save(png_path+"\ "+png_name+".png")
15 changes: 15 additions & 0 deletions BasicPythonScripts/Document Converter App/pdf_to_jpg.py
@@ -0,0 +1,15 @@
from pdf2image import convert_from_path

pdf_path = input("Enter the pdf path: ")
start_page = int(input(
"Enter the starting page number of the pdf from which the pdf should be converted to jpg: "))
end_page = int(
input("Enter the page number till which the pdf should be converted to jpg: "))

# Store Pdf with convert_from_path function
images = convert_from_path(pdf_path)

for i in range(start_page, end_page):

# Save pages as images in the pdf
images[i].save('page' + str(i) + '.jpg', 'JPEG')
15 changes: 15 additions & 0 deletions BasicPythonScripts/Document Converter App/pdf_to_png.py
@@ -0,0 +1,15 @@
from pdf2image import convert_from_path

pdf_path = input("Enter the pdf path: ")
start_page = int(input(
"Enter the starting page number of the pdf from which the pdf should be converted to jpg: "))
end_page = int(
input("Enter the page number till which the pdf should be converted to png: "))

# Store Pdf with convert_from_path function
images = convert_from_path(pdf_path)

for i in range(start_page, end_page):

# Save pages as images in the pdf
images[i].save('page' + str(i) + '.png', 'png')
14 changes: 14 additions & 0 deletions BasicPythonScripts/Document Converter App/pdf_to_word.py
@@ -0,0 +1,14 @@
# importing modules
from pdf2docx import parse

# user inputs
pdf_path=input("Enter the pdf path: ")
start_page=int(input("Enter the starting page number of the pdf from which the pdf should be converted to doc: "))
end_page=int(input("Enter the page number till which the pdf should be converted to doc: "))
doc_path=input("Enter the folder where the doc has to be saved: ")
doc_name=input("Enter the name that the doc has to be saved with: ")

f_doc=doc_path+"\ "+doc_name+".doc"

# converting pdf to word
parse(pdf_path, f_doc, start=start_page, end=end_page)
20 changes: 20 additions & 0 deletions BasicPythonScripts/Document Converter App/requirements.txt
@@ -0,0 +1,20 @@
### Install Python3
Install Python 3.x (recommended) from <a href="https://www.python.org/downloads/">here</a>

### Install win32com
pip install pywin32

### Install PILLOW
pip install Pillow

### Install pdf2docx
pip install pdf2docx

### Install pdf2pptx
pip install pdf2pptx

### Install ppt2pdf
pip install ppt2pdf

### Install pdf2image
pip install pdf2image