Skip to content

Commit e01480e

Browse files
Update _index.md
1 parent b463174 commit e01480e

File tree

1 file changed

+9
-9
lines changed
  • content/english/python-net/document-creation/creating-word-documents-using-python

1 file changed

+9
-9
lines changed

content/english/python-net/document-creation/creating-word-documents-using-python/_index.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ To get started, you'll need to download and install the Aspose.Words for Python
2828
With the library successfully installed, the next step is to initialize the Aspose.Words environment in your Python project. This initialization is crucial for effectively utilizing the library's functionality. The following code snippet demonstrates how to perform this initialization:
2929

3030
```python
31-
import asposewords
31+
import aspose.words as aw
3232

3333
# Initialize Aspose.Words environment
34-
asposewords.License().set_license('Aspose.Words.lic')
34+
aw.License().set_license('Aspose.Words.lic')
3535

3636
# Rest of the code for document generation
3737
# ...
@@ -42,11 +42,11 @@ asposewords.License().set_license('Aspose.Words.lic')
4242
With the Aspose.Words environment set up, we can now proceed to create a blank Word document as our starting point. This document will serve as the foundation upon which we'll add content programmatically. The following code illustrates how to create a new blank document:
4343

4444
```python
45-
import asposewords
45+
import aspose.words as aw
4646

4747
def create_blank_document():
4848
# Create a new blank document
49-
doc = asposewords.Document()
49+
doc = aw.Document()
5050

5151
# Save the document
5252
doc.save("output.docx")
@@ -57,7 +57,7 @@ def create_blank_document():
5757
The true power of Aspose.Words for Python lies in its ability to add rich content to the Word document. You can dynamically insert text, tables, images, and more. Below is an example of adding content to the previously created blank document:
5858

5959
```python
60-
import asposewords as aw
60+
import aspose.words as aw
6161

6262
def test_create_and_add_paragraph_node(self):
6363
doc = aw.Document()
@@ -71,17 +71,17 @@ def test_create_and_add_paragraph_node(self):
7171
To create professional-looking documents, you'll likely want to apply formatting and styling to the content you add. Aspose.Words for Python offers a wide range of formatting options, including font styles, colors, alignment, indentation, and more. Let's look at an example of applying formatting to a paragraph:
7272

7373
```python
74-
import asposewords
74+
import aspose.words as aw
7575

7676
def format_paragraph():
7777
# Load the document
78-
doc = asposewords.Document("output.docx")
78+
doc = aw.Document("output.docx")
7979

8080
# Access the first paragraph of the document
8181
paragraph = doc.first_section.body.first_paragraph
8282

8383
# Apply formatting to the paragraph
84-
paragraph.alignment = asposewords.ParagraphAlignment.CENTER
84+
paragraph.alignment = aw.ParagraphAlignment.CENTER
8585

8686
# Save the updated document
8787
doc.save("output.docx")
@@ -92,7 +92,7 @@ def format_paragraph():
9292
Tables are commonly used in Word documents to organize data. With Aspose.Words for Python, you can easily create tables and populate them with content. Below is an example of adding a simple table to the document:
9393

9494
```python
95-
import asposewords as aw
95+
import aspose.words as aw
9696

9797
def add_table_to_document():
9898
# Load the document

0 commit comments

Comments
 (0)