Skip to content

Commit 64443be

Browse files
2 parents d0006af + dacfc83 commit 64443be

File tree

4 files changed

+87
-1
lines changed

4 files changed

+87
-1
lines changed

.all-contributorsrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,24 @@
610610
"contributions": [
611611
"code"
612612
]
613+
},
614+
{
615+
"login": "samkap333",
616+
"name": "Tuba Mahmood",
617+
"avatar_url": "https://avatars.githubusercontent.com/u/68690619?v=4",
618+
"profile": "https://github.com/samkap333",
619+
"contributions": [
620+
"code"
621+
]
622+
},
623+
{
624+
"login": "atharvanaik225",
625+
"name": "atharvanaik225",
626+
"avatar_url": "https://avatars.githubusercontent.com/u/55648382?v=4",
627+
"profile": "https://github.com/atharvanaik225",
628+
"contributions": [
629+
"code"
630+
]
613631
}
614632
],
615633
"contributorsPerLine": 7,

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Automation-scripts
22
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
3-
[![All Contributors](https://img.shields.io/badge/all_contributors-67-orange.svg?style=flat-square)](#contributors-)
3+
[![All Contributors](https://img.shields.io/badge/all_contributors-69-orange.svg?style=flat-square)](#contributors-)
44
<!-- ALL-CONTRIBUTORS-BADGE:END -->
55

66
Do you know anything that can help all to easy our tough life than tell that secret to us and help us to become lazy like Panda
@@ -139,6 +139,8 @@ Thanks goes to these wonderful people 😊
139139
<td align="center"><a href="https://github.com/urmil89"><img src="https://avatars.githubusercontent.com/u/60167367?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Urmil89</b></sub></a><br /><a href="https://github.com/python-geeks/Automation-scripts/commits?author=urmil89" title="Code">💻</a></td>
140140
<td align="center"><a href="https://github.com/pranxv"><img src="https://avatars.githubusercontent.com/u/40822047?v=4?s=100" width="100px;" alt=""/><br /><sub><b>pranxv</b></sub></a><br /><a href="https://github.com/python-geeks/Automation-scripts/commits?author=pranxv" title="Code">💻</a></td>
141141
<td align="center"><a href="https://github.com/sourabh112"><img src="https://avatars.githubusercontent.com/u/66176305?v=4?s=100" width="100px;" alt=""/><br /><sub><b>sourabh112</b></sub></a><br /><a href="https://github.com/python-geeks/Automation-scripts/commits?author=sourabh112" title="Code">💻</a></td>
142+
<td align="center"><a href="https://github.com/samkap333"><img src="https://avatars.githubusercontent.com/u/68690619?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tuba Mahmood</b></sub></a><br /><a href="https://github.com/python-geeks/Automation-scripts/commits?author=samkap333" title="Code">💻</a></td>
143+
<td align="center"><a href="https://github.com/atharvanaik225"><img src="https://avatars.githubusercontent.com/u/55648382?v=4?s=100" width="100px;" alt=""/><br /><sub><b>atharvanaik225</b></sub></a><br /><a href="https://github.com/python-geeks/Automation-scripts/commits?author=atharvanaik225" title="Code">💻</a></td>
142144
</tr>
143145
</table>
144146

pdf2docx/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# PDF2DOCX
2+
3+
#### The code file (pdf2docx.py) converts the .pdf files to .docx files using 2 method. The user has the option to choose according to their preference.
4+
## 1) Converting using pdf2docx:
5+
##### The reader object parses the pdf file and stores the result in a docx file of the same name and at the same location as that of the pdf.
6+
##### This option however may result in a loss of structure or layout during conversion. This option is not suitable for files with complex layout and text.
7+
## 2) Converting using GroupDocs Cloud:
8+
##### This option is more suitable for users requiring a better quality conversion that maintains the layout and the design of the pdf. However, using this option
9+
##### will require you to set up a free account and get an App SDI as well as an API key. The user can set up a free account https://dashboard.groupdocs.cloud/

pdf2docx/pdf2docx.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Import Libraries
2+
from pdf2docx import parse
3+
from typing import Tuple
4+
import groupdocs_conversion_cloud
5+
6+
7+
def convert_pdf2docx(input_file: str, pages: Tuple = None):
8+
9+
if pages:
10+
pages = [int(i) for i in list(pages) if i.isnumeric()]
11+
result = parse(pdf_file=input_file, pages=pages)
12+
print("###### Conversion Complete #######")
13+
return result
14+
15+
16+
def cloud_convert(app_sid, app_key):
17+
convert_api = groupdocs_conversion_cloud.ConvertApi.from_keys(app_sid, app_key) # Create instance of the API
18+
file_api = groupdocs_conversion_cloud.FileApi.from_keys(app_sid, app_key)
19+
20+
try:
21+
# upload source file to storage
22+
filename = input("Please enter the complete and correct file path of the required pdf: ")
23+
remote_name = filename
24+
output_name = remote_name.split('.')[0] + "docx"
25+
remote_name = filename
26+
strformat = 'docx'
27+
28+
request_upload = groupdocs_conversion_cloud.UploadFileRequest(remote_name, filename)
29+
file_api.upload_file(request_upload)
30+
31+
# Extract Text from PDF document
32+
settings = groupdocs_conversion_cloud.ConvertSettings()
33+
settings.file_path = remote_name
34+
settings.format = strformat
35+
settings.output_path = output_name
36+
request = groupdocs_conversion_cloud.ConvertDocumentRequest(settings)
37+
response = convert_api.convert_document(request)
38+
print("Document converted successfully: " + str(response))
39+
40+
except groupdocs_conversion_cloud.ApiException as e:
41+
print("Exception when calling get_supported_conversion_types: {0}".format(e.message))
42+
43+
44+
if __name__ == "__main__":
45+
46+
choice = input("Press 1 for basic file conversion, 2 for advanced file conversion(GroupDocs account required)")
47+
while choice != '1' and choice != '2':
48+
print("Please enter a valid choice!\n")
49+
choice = input("Press 1 for basic file conversion, 2 for advanced file conversion(GroupDocs account required)")
50+
if choice == '1':
51+
52+
pdf_path = input("Please enter the complete and correct file path of the required pdf: ")
53+
convert_pdf2docx(pdf_path)
54+
else:
55+
sid = input("Enter app SID: ")
56+
api_key = input("Enter api key: ")
57+
cloud_convert(sid, api_key)

0 commit comments

Comments
 (0)