You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: en/python-net/advanced-operations/working-with-text/add-text-to-pdf-file/_index.md
+22-24Lines changed: 22 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,10 +22,10 @@ Aspose.PDF for Python via .NET. shows how to add a simple text fragment to a spe
22
22
23
23
1. Create a new Document object
24
24
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.
27
27
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)`.
29
29
1. Save the document.
30
30
31
31
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
126
126
document.save(path_outfile)
127
127
```
128
128
129
-
[]
129
+

130
130
131
131
### Add Right-to-Left (RTL) Text to PDF Document
132
132
@@ -162,7 +162,7 @@ Set font and styling. Choose a font that supports the RTL script (e.g., Tahoma,
162
162
document.save(path_outfile)
163
163
```
164
164
165
-
[]
165
+

166
166
167
167
### Add Text with Hyperlinks
168
168
@@ -204,7 +204,7 @@ Add clickable hyperlinks to text in a PDF using Aspose.PDF for Python via .NET.
204
204
document.save(path_outfile)
205
205
```
206
206
207
-
[]
207
+

208
208
209
209
## Add Text transparent
210
210
@@ -304,7 +304,7 @@ Create a TextParagraph. You can set wrap mode. In this example, we use the 'DISC
304
304
document.save(path_outfile)
305
305
```
306
306
307
-
[]
307
+

308
308
309
309
### Add Text with Indents in PDF
310
310
@@ -316,16 +316,14 @@ It shows how to control both the first line indent and the subsequent line inden
316
316
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.
317
317
1. Initialize a TextBuilder. It used to place TextParagraph objects on a page.
318
318
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.
320
320
1. Save the document.
321
321
322
322
You can also modify:
323
323
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.
329
327
330
328
```python
331
329
@@ -396,7 +394,7 @@ Aspose.PDF for Python via .NET library allows you to insert HTML-formatted conte
396
394
document.save(path_outfile)
397
395
```
398
396
399
-
[]
397
+

400
398
401
399
### Add LaTeX Text to PDF Document
402
400
@@ -426,7 +424,7 @@ LaTeX is a powerful typesetting system widely used for creating scientific and m
426
424
document.save(path_outfile)
427
425
```
428
426
429
-
[]
427
+

430
428
431
429
### Add HTML Fragment to PDF Document
432
430
@@ -459,7 +457,7 @@ We can define an HTML fragment and set the text style directly using HTML tags.
459
457
document.save(path_outfile)
460
458
```
461
459
462
-
[]
460
+

463
461
464
462
### Add HTML Fragment override text state
465
463
@@ -497,7 +495,7 @@ Insert styled HTML content into a PDF document, while overriding the default tex
497
495
document.save(path_outfile)
498
496
```
499
497
500
-
[]
498
+

501
499
502
500
## Using Line Spacing
503
501
@@ -589,7 +587,7 @@ The example shows how line spacing behavior can vary depending on the selected m
589
587
document.save(path_outfile)
590
588
```
591
589
592
-
[]
590
+

593
591
594
592
## Using Character Spacing
595
593
@@ -628,7 +626,7 @@ Character spacing determines the distance between individual characters in a lin
### How to control character spacing in PDF text using the TextParagraph and TextBuilder
634
632
@@ -795,11 +793,11 @@ Our library shows how to create a bulleted (unordered) list in a PDF document us
795
793
document.save(path_outfile)
796
794
```
797
795
798
-
[]
796
+

799
797
800
798
### Create numbered list HTML version
801
799
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.
803
801
804
802
Using HTML fragments enables you to incorporate HTML-based formatting features, such as numbered lists, bold, italics, and more, directly in your PDF.
805
803
@@ -833,7 +831,7 @@ Using HTML fragments enables you to incorporate HTML-based formatting features,
833
831
document.save(path_outfile)
834
832
```
835
833
836
-
[]
834
+

837
835
838
836
### Create a bullet list LaTeX version
839
837
@@ -869,7 +867,7 @@ Create a bulleted (unordered) list in a PDF using LaTeX fragments (TeXFragment).
869
867
document.save(path_outfile)
870
868
```
871
869
872
-
[]
870
+

873
871
874
872
### Create numbered list LaTeX version
875
873
@@ -903,7 +901,7 @@ Create a numbered (ordered) list in a PDF using LaTeX fragments (TeXFragment). I
903
901
document.save(path_outfile)
904
902
```
905
903
906
-
[]
904
+

0 commit comments