Skip to content

Staging #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions content/english/python-net/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ Master word document processing using Aspose.Words for Python. Tutorials offer p
Master document creation with Aspose.Words for Python. Create dynamic documents, customize formatting, and streamline word document processing.
### [Word Automation](./word-automation/)
Automate word processing tasks with Aspose.Words for Python. Streamline document management and boost efficiency in word automation.
### [Document Intelligence](./document-intelligence/)
Unlock valuable insights from your documents with Aspose.Words for Python's Document Intelligence. Automate analysis, text extraction, and classification.
### [Document Conversion](./document-conversion/)
Efficiently convert documents between formats with Aspose.Words for Python. Streamline word document processing and simplify your document management tasks.
### [Document Protection](./document-protection/)
Secure your documents with Aspose.Words for Python! Implement password encryption, user permissions, and digital signatures for robust document protection.
### [Document Structure and Content Manipulation](./document-structure-and-content-manipulation/)
Explore Aspose.Words tutorials for Python and .NET, focusing on document structure and content manipulation. Learn how to navigate, extract, and modify document elements efficiently. Source code examples provided.
### [Content Extraction and Manipulation](./content-extraction-and-manipulation/)
Expand All @@ -42,7 +38,5 @@ Discover comprehensive tutorials on document combining and comparison using Aspo
Explore the Aspose.Words tutorials on document splitting and formatting in Python and .NET. Learn to split and format documents efficiently, enhancing your document processing tasks.
### [Document Options and Settings](./document-options-and-settings/)
Explore Aspose.Words tutorials on document options and settings in Python and .NET. Learn to optimize document creation and formatting using step-by-step guidance and source code examples.
### [Data Visualization and Formatting](./data-visualization-and-formatting/)
Discover Aspose.Words tutorials on data visualization and formatting in Python and .NET. Learn to present data effectively, create stunning reports, and format documents programmatically.
### [Tables and Formatting](./tables-and-formatting/)
Dive into Aspose.Words tutorials on tables and formatting in Python and .NET applications. Learn to create, customize, and style tables for visually compelling documents.
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,6 @@ for paragraph in doc.get_child_nodes(doc.is_paragraph, True):
text += paragraph.get_text()
```

## Extracting Images

To extract images from the document:

```python
for shape in doc.get_child_nodes(doc.is_shape, True):
if shape.has_image:
image = shape.image_data.to_bytes()
with open("image.png", "wb") as f:
f.write(image)
```

## Managing Formatting

Preserving formatting during extraction:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ for para in doc.get_child_nodes(asposewords.NodeType.PARAGRAPH, True):
print(text)
```

## Modifying Text

You can modify text by directly setting the text of runs or paragraphs:

```python
for para in doc.get_child_nodes(asposewords.NodeType.PARAGRAPH, True):
if "old_text" in para.get_text():
para.get_runs().get(0).set_text("new_text")
```

## Working with Formatting

Aspose.Words allows you to work with formatting styles:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,6 @@ for paragraph in doc.get_child_nodes(aw.NodeType.PARAGRAPH, True):
paragraph.get_range().replace(text_to_remove, replacement, False, False)
```

## Replacing Text

Sometimes, you might want to replace certain text with new content. Here's an example of how to do it:

```python
text_to_replace = "old text"
new_text = "new text"

for paragraph in doc.get_child_nodes(aw.NodeType.PARAGRAPH, True):
if text_to_replace in paragraph.get_text():
paragraph.get_range().replace(text_to_replace, new_text, False, False)
```

## Removing Images

If you need to remove images from the document, you can use a similar approach. First, identify the images and then remove them:
Expand Down Expand Up @@ -94,22 +81,6 @@ for section in doc.sections:
doc.remove_child(section)
```

## Find and Replace with Regex

Regular expressions offer a powerful way to find and replace content:

```python
import re

pattern = r"\b\d{4}\b" # Example: Replace four-digit numbers
replacement = "****"

for paragraph in doc.get_child_nodes(aw.NodeType.PARAGRAPH, True):
text = paragraph.get_text()
new_text = re.sub(pattern, replacement, text)
paragraph.get_range().text = new_text
```

## Extracting Specific Content

Sometimes, you might need to extract specific content from a document:
Expand Down

This file was deleted.

This file was deleted.

Loading