diff --git a/Python-with-Office-Video_Covers.pptx b/Python-with-Office-Video_Covers.pptx index 0930102..7aeea01 100644 Binary files a/Python-with-Office-Video_Covers.pptx and b/Python-with-Office-Video_Covers.pptx differ diff --git a/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-1_use-section_1.py b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-1_use-section_1.py new file mode 100644 index 0000000..0d9a999 --- /dev/null +++ b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-1_use-section_1.py @@ -0,0 +1,10 @@ +from docx import Document +doc = Document() + +print(type(doc)) + +print(type(doc.sections)) + +section = doc.sections[0] + +print(type(section)) \ No newline at end of file diff --git a/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-1_use-section_2.py b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-1_use-section_2.py new file mode 100644 index 0000000..e68775b --- /dev/null +++ b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-1_use-section_2.py @@ -0,0 +1,8 @@ +from docx import Document +doc = Document() + +section1 = doc.add_section() + +section2 = doc.add_section() + +print(len(doc.sections)) \ No newline at end of file diff --git a/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-2_section-divider.py b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-2_section-divider.py new file mode 100644 index 0000000..0daf6fe --- /dev/null +++ b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-2_section-divider.py @@ -0,0 +1,19 @@ +from docx import Document +from docx.enum.section import WD_SECTION_START + +doc = Document() + +s1 = doc.add_section() +print(s1.start_type) + +s2 = doc.add_section(WD_SECTION_START.NEW_PAGE) +print(s2.start_type) + +s3 = doc.add_section(WD_SECTION_START.CONTINUOUS) +print(s3.start_type) + +s4 = doc.add_section(WD_SECTION_START.EVEN_PAGE) +print(s4.start_type) + +s5 = doc.add_section(WD_SECTION_START.ODD_PAGE) +print(s5.start_type) \ No newline at end of file diff --git a/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-3_2.docx b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-3_2.docx new file mode 100644 index 0000000..10bf021 Binary files /dev/null and b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-3_2.docx differ diff --git a/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-3_paper-size_1.py b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-3_paper-size_1.py new file mode 100644 index 0000000..fd1a62a --- /dev/null +++ b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-3_paper-size_1.py @@ -0,0 +1,10 @@ +from docx import Document +doc = Document() + +section = doc.sections[0] + +# python-docx is using "Letter" size as default + +print(section.page_width.cm) + +print(section.page_height.mm) \ No newline at end of file diff --git a/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-3_paper-size_2.py b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-3_paper-size_2.py new file mode 100644 index 0000000..328d47d --- /dev/null +++ b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-3_paper-size_2.py @@ -0,0 +1,42 @@ +from docx import Document +from docx.shared import Cm + +doc = Document() + +section = doc.sections[0] + +# python-docx is using "Letter" size as default + +print(section.page_width.cm) + +print(section.page_height.mm) + +# set Page size to A4 + +section.page_width = Cm(21.0) +section.page_height = Cm(29.7) + +print(section.page_width.cm) + +print(section.page_height.mm) + +# set Page size to Legal + +section.page_width = Cm(21.59) +section.page_height = Cm(35.56) + +print(section.page_width.cm) + +print(section.page_height.mm) + +# set Page size to non-standard + +section.page_width = Cm(11.59) +section.page_height = Cm(25.56) + +print(section.page_width.cm) + +print(section.page_height.mm) + + +doc.save("./7-11-3_2.docx") \ No newline at end of file diff --git a/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-4_1.docx b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-4_1.docx new file mode 100644 index 0000000..11ec9bf Binary files /dev/null and b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-4_1.docx differ diff --git a/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-4_2.docx b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-4_2.docx new file mode 100644 index 0000000..0408359 Binary files /dev/null and b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-4_2.docx differ diff --git a/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-4_orientation_1.py b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-4_orientation_1.py new file mode 100644 index 0000000..ddb9a53 --- /dev/null +++ b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-4_orientation_1.py @@ -0,0 +1,14 @@ +from docx import Document +from docx.enum.section import WD_ORIENTATION + +doc = Document() + +section = doc.sections[0] + +print(section.orientation) + +section.orientation = WD_ORIENTATION.LANDSCAPE + +print(section.orientation) + +doc.save("./7-11-4_1.docx") \ No newline at end of file diff --git a/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-4_orientation_2.py b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-4_orientation_2.py new file mode 100644 index 0000000..9a36b87 --- /dev/null +++ b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-4_orientation_2.py @@ -0,0 +1,16 @@ +from docx import Document +from docx.enum.section import WD_ORIENTATION + +doc = Document() + +section = doc.sections[0] + +section.orientation = WD_ORIENTATION.LANDSCAPE + +width = section.page_width +height = section.page_height + +section.page_width = height +section.page_height = width + +doc.save("./7-11-4_2.docx") \ No newline at end of file diff --git a/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-5.docx b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-5.docx new file mode 100644 index 0000000..06d6e69 Binary files /dev/null and b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-5.docx differ diff --git a/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-5_margin.py b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-5_margin.py new file mode 100644 index 0000000..cba48a1 --- /dev/null +++ b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-5_margin.py @@ -0,0 +1,23 @@ +from docx import Document +from docx.shared import Cm + +doc = Document() + +section = doc.sections[0] + +print(section.top_margin.cm) +print(section.bottom_margin.cm) +print(section.left_margin.cm) +print(section.right_margin.cm) + +section.top_margin = Cm(2) +section.bottom_margin = Cm(1) +section.left_margin = Cm(1.5) +section.right_margin = Cm(4) + +print(section.top_margin.cm) +print(section.bottom_margin.cm) +print(section.left_margin.cm) +print(section.right_margin.cm) + +doc.save("./7-11-5.docx") \ No newline at end of file diff --git a/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-6_gutter.py b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-6_gutter.py new file mode 100644 index 0000000..fb86c90 --- /dev/null +++ b/part2_Use-Python-in-Office/ch07_work-with-word/7-11_page-setup/7-11-6_gutter.py @@ -0,0 +1,12 @@ +from docx import Document +from docx.shared import Cm + +doc = Document() + +section = doc.sections[0] + +print(section.gutter.cm) + +section.gutter = Cm(1.0) + +print(section.gutter.cm) \ No newline at end of file