Skip to content

Commit 9e103b6

Browse files
Merge pull request #396 from telerik/dess-docs-feedback
update TextFragments
2 parents aedbd4f + 66f479c commit 9e103b6

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed
Loading

libraries/radpdfprocessing/model/textfragment.md

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,48 @@ position: 3
88
---
99

1010
# TextFragment
11-
12-
13-
14-
__TextFragment__ is content element that represents а single-line text object.
15-
11+
__TextFragment__ is content element that represents а single-line text object.
1612

1713
* [Inserting a TextFragment](#inserting-a-textfragment)
1814

19-
* [Modifying a TextFragment](#modifying-a-textfragment)
20-
15+
* [Modifying a TextFragment](#modifying-a-textfragment)
2116

2217
## Inserting a TextFragment
2318

24-
__TextFragment__ is a content element that can be added in the __Content__ collection of a __IContainerElement__ such as [RadFixedPage]({%slug radpdfprocessing-model-radfixedpage%}). There are several approaches that can be adopted.
25-
19+
__TextFragment__ is a content element that can be added in the __Content__ collection of a __IContainerElement__ such as [RadFixedPage]({%slug radpdfprocessing-model-radfixedpage%}). There are several approaches that can be adopted:
2620

27-
__Example 1__ shows how you can initialize a TextFragment object and add it to a previously defined container.
28-
21+
* Create a TextFragment and add it to a page container
22+
* Use one of the factory methods of the __ContentElementCollection__ to create a new text fragment and insert it into the respective container
23+
24+
Both methods return the actual TextFragment instance so you can modify it.
2925

3026
#### __[C#] Example 1: Create TextFragment and add it to container__
3127

3228
{{region cs-radpdfprocessing-model-textfragment_0}}
33-
TextFragment fragment = new TextFragment();
34-
container.Content.Add(fragment);
35-
{{endregion}}
36-
37-
38-
39-
__Example 2__ demonstrates how to use one of the factory methods of the __ContentElementCollection__, which create new text fragment and insert it into the respective container. Both methods return the actual TextFragment instance so you can modify it.
40-
41-
42-
#### __[C#] Example 2: Add TextFragment to container__
43-
44-
{{region cs-radpdfprocessing-model-textfragment_1}}
45-
TextFragment textFragment = container.Content.AddTextFragment();
46-
TextFragment textFragmentWithText = container.Content.AddTextFragment("Text");
29+
RadFixedDocument document = new RadFixedDocument();
30+
RadFixedPage page = new RadFixedPage();
31+
document.Pages.Add(page);
32+
FixedContentEditor editor = new FixedContentEditor(page);
33+
34+
SimplePosition simplePosition = new SimplePosition();
35+
simplePosition.Translate(20, 20);
36+
TextFragment textFragment = page.Content.AddTextFragment("Document Processing Libraries");
37+
textFragment.CharacterSpacing = 5;
38+
textFragment.WordSpacing = 15;
39+
textFragment.Position = simplePosition;
40+
41+
SimplePosition simplePosition2 = new SimplePosition();
42+
simplePosition2.Translate(20, 120);
43+
TextFragment textFragment2 = new TextFragment("Document Processing Libraries");
44+
textFragment2.CharacterSpacing = 10;
45+
textFragment2.WordSpacing = 20;
46+
textFragment2.Position = simplePosition2;
47+
page.Content.Add(textFragment2);
4748
{{endregion}}
4849

50+
>caption Inserted TextFragments
4951
52+
![TextFragments in PdfProcessing](images/radpdfprocessing-model-textfragment.png)
5053

5154
>tip__TextFragment__ represents a single line of text. In order to make your text "flows" in a document you should make sure all fragments you add can fit in a line or you can use [FixedContentEditor]({%slug radpdfprocessing-editing-fixedcontenteditor%}).
5255

0 commit comments

Comments
 (0)