-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwriteD.py
More file actions
34 lines (27 loc) · 786 Bytes
/
Copy pathwriteD.py
File metadata and controls
34 lines (27 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from docx import Document
from docx.shared import Inches
class writeDoc:
def __init__(self):
self.document = Document()
def addHeading(self,heading):
self.document.add_heading(heading, 0)
def addParagraph(self,paragraph):
p = self.document.add_paragraph(paragraph)
def addImage(self,img_path):
self.document.add_picture(img_path, width=Inches(1.25))
def addPage_break(self):
self.document.add_page_break()
pass
def saveDoc(self,name):
self.document.save(name)
#self.document.cleanup()
'''
d1=writeDoc()
d1.addHeading("First Doc")
d1.addParagraph("My doc")
d1.saveDoc("./documents/Anshu.docx")
d1=writeDoc()
d1.addHeading("Second Doc")
d1.addParagraph("My doc")
d1.saveDoc("Anshu1.docx")
'''