@@ -34,23 +34,23 @@ pip install aspose-words
34
34
3 . Import the library in your Python script.
35
35
36
36
``` python
37
- import aspose.words
37
+ import aspose.words as aw
38
38
```
39
39
40
40
## Creating a New Document
41
41
42
42
Let's start by creating a new document using Aspose.Words:
43
43
44
44
``` python
45
- document = aspose.words .Document()
45
+ document = aw .Document()
46
46
```
47
47
48
48
## Adding Content to the Document
49
49
50
50
You can easily add content to the document using Aspose.Words:
51
51
52
52
``` python
53
- builder = aspose.words .DocumentBuilder(document)
53
+ builder = aw .DocumentBuilder(document)
54
54
builder.writeln(" Hello, world!" )
55
55
```
56
56
@@ -61,28 +61,8 @@ Styling and formatting play a crucial role in document presentation. Aspose.Word
61
61
``` python
62
62
font = builder.font
63
63
font.bold = True
64
- font.size = aspose.words.Size(16 )
65
- font.color = aspose.words.Color.from_argb(255 , 0 , 0 , 0 )
66
- ```
67
-
68
- ## Inserting Web Extensions
69
-
70
- To insert a web extension into the document, follow these steps:
71
-
72
- 1 . Create the web extension using HTML, CSS, and JavaScript.
73
- 2 . Convert the web extension into a base64-encoded string.
74
-
75
- ``` python
76
- extension_html = " <div>Your web extension content</div>"
77
- extension_base64 = aspose.words.Convert.to_base64_string(extension_html)
78
- ```
79
-
80
- 3 . Insert the web extension into the document:
81
-
82
- ``` python
83
- extension_node = aspose.words.DrawingML.Inline(doc)
84
- extension_node.image_data.set_source(extension_base64)
85
- builder.insert_node(extension_node)
64
+ font.size = aw.Size(16 )
65
+ font.color = aw.Color.from_argb(255 , 0 , 0 , 0 )
86
66
```
87
67
88
68
## Interacting with Web Extensions
@@ -98,7 +78,7 @@ Web extensions can dynamically modify document content. For instance, you can us
98
78
After incorporating web extensions and making necessary modifications, you can save the document using various formats supported by Aspose.Words:
99
79
100
80
``` python
101
- document.save(" output.docx" , aspose.words.SaveFormat. DOCX )
81
+ document.save(" output.docx" )
102
82
```
103
83
104
84
## Tips for Performance Optimization
0 commit comments