Skip to content

Commit 8e6186c

Browse files
committed
chore: improve clarity and formatting in PDF text manipulation documentation
1 parent a3914ad commit 8e6186c

File tree

1 file changed

+22
-24
lines changed
  • en/python-net/advanced-operations/working-with-text/add-text-to-pdf-file

1 file changed

+22
-24
lines changed

en/python-net/advanced-operations/working-with-text/add-text-to-pdf-file/_index.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ Aspose.PDF for Python via .NET. shows how to add a simple text fragment to a spe
2222

2323
1. Create a new Document object
2424
1. Use 'document.pages.add()' to create a new blank page.
25-
1. Create a TextFragment().
26-
1. Set the text position using the Position() class. If you specify Position(), the text will be located in your document from left to right and shifted downwards.
25+
1. Create a `TextFragment`.
26+
1. Set the text position using the Position class. If you specify Position, the text will be located in your document from left to right and shifted downwards.
2727
1. Customize text appearance. You can set font size, color, font style, and more via text_fragment.text_state.
28-
1. Append the TextFragment to the page’s paragraph collection with page.paragraphs.add(text_fragment).
28+
1. Append the TextFragment to the page’s paragraph collection with `page.paragraphs.add(text_fragment)`.
2929
1. Save the document.
3030

3131
The following code snippet shows you how to add text in an existing PDF file:
@@ -126,7 +126,7 @@ Additionally, this code snippet shows how to use multiple text segments within a
126126
document.save(path_outfile)
127127
```
128128

129-
[![Add Text with Font Styling](styled_text.png)]
129+
![Text fragment displayed with blue italic Arial font containing the text Hello, Aspose! followed by a mathematical formula showing S = a subscript 2n + a subscript 2n+1 + a subscript 2n+2 with blue main text and red subscript formatting](styled_text.png)
130130

131131
### Add Right-to-Left (RTL) Text to PDF Document
132132

@@ -162,7 +162,7 @@ Set font and styling. Choose a font that supports the RTL script (e.g., Tahoma,
162162
document.save(path_outfile)
163163
```
164164

165-
[![Right-to-Left Text](rtl_text.png)]
165+
![Right-to-Left Text](rtl_text.png)
166166

167167
### Add Text with Hyperlinks
168168

@@ -204,7 +204,7 @@ Add clickable hyperlinks to text in a PDF using Aspose.PDF for Python via .NET.
204204
document.save(path_outfile)
205205
```
206206

207-
[![Text with Hyperlinks](hyperlink_text.png)]
207+
![Text fragment displayed in a PDF showing mixed content with Sample Text Fragment followed by Text Segment 1, then a blue hyperlinked text reading Link to Google, and ending with TextSegment without hyperlink in regular black text formatting](hyperlink_text.png)
208208

209209
## Add Text transparent
210210

@@ -304,7 +304,7 @@ Create a TextParagraph. You can set wrap mode. In this example, we use the 'DISC
304304
document.save(path_outfile)
305305
```
306306

307-
[![Add Text using TextParagraph](text_paragraph.png)]
307+
![Add Text using TextParagraph](text_paragraph.png)
308308

309309
### Add Text with Indents in PDF
310310

@@ -316,16 +316,14 @@ It shows how to control both the first line indent and the subsequent line inden
316316
1. Create and style a text fragment. Use TextFragment(text) to hold the content. Apply basic styling (font and size) via the text_state property.
317317
1. Initialize a TextBuilder. It used to place TextParagraph objects on a page.
318318
1. Add the first paragraph with 'first_line_indent'. It offsets only the first line of the paragraph. The rectangle defines the area where text will appear. Use 'wrap_mode = BY_WORDS' to ensure natural word wrapping.
319-
1. Add a second paragraph with 'subsequent_lines_indent'. It offsets all lines after the first.
319+
1. Add a second paragraph with `subsequent_lines_indent`. It offsets all lines after the first.
320320
1. Save the document.
321321

322322
You can also modify:
323323

324-
- 'fragment.text_state.foreground_color' - for text color.
325-
326-
- 'fragment.text_state.font_style' - for bold/italic/underline.
327-
328-
- 'fragment.text_state.line_spacing' - for spacing between lines.
324+
- `fragment.text_state.foreground_color` - for text color.
325+
- `fragment.text_state.font_style` - for bold/italic/underline.
326+
- `fragment.text_state.line_spacing` - for spacing between lines.
329327

330328
```python
331329

@@ -396,7 +394,7 @@ Aspose.PDF for Python via .NET library allows you to insert HTML-formatted conte
396394
document.save(path_outfile)
397395
```
398396

399-
[![Add HTML Text to a PDF Document](html_fragment.png)]
397+
![Add HTML Text to a PDF Document](html_fragment.png)
400398

401399
### Add LaTeX Text to PDF Document
402400

@@ -426,7 +424,7 @@ LaTeX is a powerful typesetting system widely used for creating scientific and m
426424
document.save(path_outfile)
427425
```
428426

429-
[![Add LaTeX Text to a PDF Document](latex_fragment.png)]
427+
![Add LaTeX Text to a PDF Document](latex_fragment.png)
430428

431429
### Add HTML Fragment to PDF Document
432430

@@ -459,7 +457,7 @@ We can define an HTML fragment and set the text style directly using HTML tags.
459457
document.save(path_outfile)
460458
```
461459

462-
[![Add HTML Content to a PDF Document](html_content.png)]
460+
![Add HTML Content to a PDF Document](html_content.png)
463461

464462
### Add HTML Fragment override text state
465463

@@ -497,7 +495,7 @@ Insert styled HTML content into a PDF document, while overriding the default tex
497495
document.save(path_outfile)
498496
```
499497

500-
[![Add HTML fragment override text state](html_override.png)]
498+
![Add HTML fragment override text state](html_override.png)
501499

502500
## Using Line Spacing
503501

@@ -589,7 +587,7 @@ The example shows how line spacing behavior can vary depending on the selected m
589587
document.save(path_outfile)
590588
```
591589

592-
[![Custom Line Spacing](line_spacing.png)]
590+
![Custom Line Spacing](line_spacing.png)
593591

594592
## Using Character Spacing
595593

@@ -628,7 +626,7 @@ Character spacing determines the distance between individual characters in a lin
628626
document.save(path_outfile)
629627
```
630628

631-
[![Character Spacing](character_spacing_simple.png)]
629+
![Character Spacing](character_spacing_simple.png)
632630

633631
### How to control character spacing in PDF text using the TextParagraph and TextBuilder
634632

@@ -795,11 +793,11 @@ Our library shows how to create a bulleted (unordered) list in a PDF document us
795793
document.save(path_outfile)
796794
```
797795

798-
[![Bullet list HTML](bullet_list_html.png)]
796+
![Bullet list HTML](bullet_list_html.png)
799797

800798
### Create numbered list HTML version
801799

802-
Create a numbered (ordered) list in a PDF document using HTML fragments. It converts a Python list of strings into an HTML <ol> element and inserts it into a PDF page as an HtmlFragment.
800+
Create a numbered (ordered) list in a PDF document using HTML fragments. It converts a Python list of strings into an HTML `<ol>` element and inserts it into a PDF page as an HtmlFragment.
803801

804802
Using HTML fragments enables you to incorporate HTML-based formatting features, such as numbered lists, bold, italics, and more, directly in your PDF.
805803

@@ -833,7 +831,7 @@ Using HTML fragments enables you to incorporate HTML-based formatting features,
833831
document.save(path_outfile)
834832
```
835833

836-
[![Numbered list HTML ](numbered_list_html.png)]
834+
![Numbered list HTML ](numbered_list_html.png)
837835

838836
### Create a bullet list LaTeX version
839837

@@ -869,7 +867,7 @@ Create a bulleted (unordered) list in a PDF using LaTeX fragments (TeXFragment).
869867
document.save(path_outfile)
870868
```
871869

872-
[![Bullet list LaTex](bullet_list_latex.png)]
870+
![Bullet list LaTex](bullet_list_latex.png)
873871

874872
### Create numbered list LaTeX version
875873

@@ -903,7 +901,7 @@ Create a numbered (ordered) list in a PDF using LaTeX fragments (TeXFragment). I
903901
document.save(path_outfile)
904902
```
905903

906-
[![Numbered list LaTex](numbered_list_latex.png)]
904+
![Numbered list displayed in PDF showing LaTeX-rendered formatting with items 1. First item, 2. Second item with more text to demonstrate wrapping behavior, 3. Third item, and 4. Fourth item, preceded by the text Lists are easy to create](numbered_list_latex.png)
907905

908906
## Using Custom Fonts
909907

0 commit comments

Comments
 (0)