Skip to content

Commit

Permalink
Merge pull request #417 from telerik/yoan/docs-feedback
Browse files Browse the repository at this point in the history
Yoan/docs feedback
  • Loading branch information
dessyordanova authored Aug 29, 2024
2 parents 99f8ba0 + 6441deb commit 943845b
Show file tree
Hide file tree
Showing 17 changed files with 239 additions and 128 deletions.
File renamed without changes
2 changes: 1 addition & 1 deletion knowledge-base/quote-worksheet-values-and-csv-export.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ using (StreamWriter writer = new StreamWriter(stream))
}
}
```
![Before - After quoting and exporting to CSV ](images/quotedCsvValus.png)
![Before - After quoting and exporting to CSV ](images/quoted-csv-values.png)

## See Also

Expand Down
20 changes: 18 additions & 2 deletions libraries/radpdfprocessing/concepts/fonts.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,16 @@ There are 14 *Type 1* fonts, known as the standard 14 fonts, that are not embedd
| Symbol|
| ZapfDingbats|


{{region cs-radpdfprocessing-concepts-fonts_0}}

FontBase helvetica = FontsRepository.Helvetica;

{{endregion}}

>tip These fonts, or their font metrics and suitable substitution fonts, must be available to the consumer application.

## Embedded Fonts

All fonts, which are not included in the 14 standard ones, should be **embedded** in the PDF document. Otherwise, the result may be unpredictable when the document is rendered. In __RadPdfProcessing__ you have the ability to embed fonts following the approaches described below.
Expand All @@ -93,7 +101,7 @@ __Example 1__ demonstrates how you can use the RegisterFont() method.

#### __[C#] Example 1: Register font in .NET Framework application__

{{region cs-radpdfprocessing-concepts-fonts_0}}
{{region cs-radpdfprocessing-concepts-fonts_1}}

// Read the font file
byte[] fontData = File.ReadAllBytes("some-font.ttf");
Expand All @@ -119,12 +127,20 @@ __Example 1__ demonstrates how you can use the RegisterFont() method.

>tip Each registered font can be obtained from the font repository as __FontBase__ object and applied to a __[TextFragment]({%slug radpdfprocessing-model-textfragment%})__ through its __Font__ property.
{{region cs-radpdfprocessing-concepts-fonts_3}}

FontBase courier = FontsRepository.Courier;
TextFragment textFragment = new TextFragment();
textFragment.Font = courier;

{{endregion}}

__Example 2__ shows how to create a font using the FontsRepository.


#### __[C#] Example 2: Create FontBase__

{{region cs-radpdfprocessing-concepts-fonts_1}}
{{region cs-radpdfprocessing-concepts-fonts_4}}
FontBase font;
bool success = FontsRepository.TryCreateFont(fontFamily, fontStyle, fontWeight, out font);
{{endregion}}
Expand Down
58 changes: 35 additions & 23 deletions libraries/radpdfprocessing/editing/fixedcontenteditor.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ __FixedContentEditor__ is always associated with a single [RadFixedPage]({%slug
#### __[C#] Example 1: Create FixedContentEditor__

{{region cs-radpdfprocessing-editing-fixedcontenteditor_0}}
FixedContentEditor editor = new FixedContentEditor(contentRootElement);
RadFixedDocument document = new RadFixedDocument();
var firstPage = document.Pages.AddPage();

FixedContentEditor fixedContentEditor = new FixedContentEditor(firstPage);
{{endregion}}

The editor maintains an internal [Position]({%slug radpdfprocessing-concepts-position%}) inside the content root element. When a new element is created, its position is being set to the current position of the editor. The initial position of the editor can be specified when it is created.
Expand All @@ -55,7 +58,16 @@ __Example 2__ demonstrates how you can create a FixedContentEditor with a specif
#### __[C#] Example 2: Create FixedContentEditor with a specific position__

{{region cs-radpdfprocessing-editing-fixedcontenteditor_1}}
FixedContentEditor editor = new FixedContentEditor(contentRootElement, initialPosition);
MatrixPosition matrixPosition = new MatrixPosition();
matrixPosition.Translate(20, 20); // Translates the position by (20, 20)
matrixPosition.Translate(30, 30); // Translates the position by (30, 30).

SimplePosition simplePosition = new SimplePosition();
simplePosition.Translate(20, 20); // Translates the position by (20, 20).
simplePosition.Translate(30, 30); // Translates the position by (30, 30) overwriting the previous translations.

FixedContentEditor simplePositionfixedContentEditor = new FixedContentEditor(firstPage,matrixPosition);
FixedContentEditor matrixPositionfixedContentEditor = new FixedContentEditor(firstPage,matrixPosition);
{{endregion}}

## Inserting Elements
Expand All @@ -69,7 +81,7 @@ Inserting a [TextFragment]({%slug radpdfprocessing-model-textfragment%}) can be
#### __[C#] Example 3: Insert TextFragment__

{{region cs-radpdfprocessing-editing-fixedcontenteditor_2}}
editor.DrawText("First text fragment.");
fixedContentEditor.DrawText("First text fragment.");
{{endregion}}

__Figure 1__ shows the result of __Example 3__.
Expand All @@ -90,7 +102,7 @@ __Example 4__ shows how you can use the __Block__ object to draw a paragraph.
Block block = new Block();
block.InsertText("First sentence.");
block.InsertText("Second sentence.");
editor.DrawBlock(block);
fixedContentEditor.DrawBlock(block);
{{endregion}}

__Figure 2__ shows the result of __Example 4__.
Expand Down Expand Up @@ -119,7 +131,7 @@ __Example 5__ shows how you can add an image created from a Stream.
{{region cs-radpdfprocessing-editing-fixedcontenteditor_4}}
using (Stream stream = this.GetResourceStream("Telerik_logo.jpg"))
{
editor.DrawImage(stream, new Size(118, 28));
fixedContentEditor.DrawImage(stream, new Size(118, 28));
}
{{endregion}}

Expand All @@ -141,7 +153,7 @@ __Example 6__ shows how you can add an ellipse using one of FixedContentEditor's
#### __[C#] Example 6: Insert ellipse__

{{region cs-radpdfprocessing-editing-fixedcontenteditor_5}}
editor.DrawEllipse(new Point(250, 70), 136, 48);
fixedContentEditor.DrawEllipse(new Point(250, 70), 136, 48);
{{endregion}}

### Inserting Clipping
Expand All @@ -167,7 +179,7 @@ When a new clipping is pushed, it is set as a clipping to the current clipping i

using (editor.PushClipping(new Rect(new Point(0, 0), visisibleTextSize)))
{
editor.DrawText(text);
fixedContentEditor.DrawText(text);
}
{{endregion}}

Expand Down Expand Up @@ -201,8 +213,8 @@ __Example 8__ generates a table and draws it in some fixed size.
RadFixedDocument document = new RadFixedDocument();
RadFixedPage page = document.Pages.AddPage();
FixedContentEditor editor = new FixedContentEditor(page);
editor.Position.Translate(10, 10);
editor.DrawTable(table, new Size(180, double.PositiveInfinity));
fixedContentEditor.Position.Translate(10, 10);
fixedContentEditor.DrawTable(table, new Size(180, double.PositiveInfinity));
{{endregion}}

#### The table created in Example 8
Expand All @@ -217,7 +229,7 @@ With the FixedContentEditor class you can insert a Form (Form-XObject) element.

#### __[C#] Example 9: Insert a form__
{{region cs-radpdfprocessing-editing-fixedcontenteditor_9}}
editor.DrawForm(formSource);
fixedContentEditor.DrawForm(formSource);
{{endregion}}

There are two more overloads of DrawForm() that enable you to pass the size that should be used for the form.
Expand All @@ -238,8 +250,8 @@ The Widget annotations allow you visualize the content of a FormField. With the

document.AcroForm.FormFields.Add(pushButton);

editor.Position.Translate(20, 450);
editor.DrawWidget(pushButton, new Size(100, 20));
fixedContentEditor.Position.Translate(20, 450);
fixedContentEditor.DrawWidget(pushButton, new Size(100, 20));
{{endregion}}

* **DrawWidget(RadioButtonField parentField, RadioOption option, Size annotationSize)**: Creates new [RadioButtonWidget]({%slug radpdfprocessing-model-annotations-widgets%}#radiobuttonwidget-class) and draws the widget with the specified annotation size. This method will add widget only in cases when the root of the FixedContentEditor supports annotations. The second parameter represents the option that should be visualized by the widget.
Expand All @@ -256,12 +268,12 @@ The Widget annotations allow you visualize the content of a FormField. With the

document.AcroForm.FormFields.Add(radio);
editor.Position.Translate(20, 410);
editor.DrawWidget(radio, radio.Options[0], new Size(20, 20));
editor.Position.Translate(50, 410);
editor.DrawWidget(radio, radio.Options[1], new Size(20, 20));
editor.Position.Translate(80, 410);
editor.DrawWidget(radio, radio.Options[2], new Size(20, 20));
fixedContentEditor.Position.Translate(20, 410);
fixedContentEditor.DrawWidget(radio, radio.Options[0], new Size(20, 20));
fixedContentEditor.Position.Translate(50, 410);
fixedContentEditor.DrawWidget(radio, radio.Options[1], new Size(20, 20));
fixedContentEditor.Position.Translate(80, 410);
fixedContentEditor.DrawWidget(radio, radio.Options[2], new Size(20, 20));
{{endregion}}

## Positioning
Expand All @@ -273,13 +285,13 @@ The code in __Example 12__ shows how to manipulate the position of the inserted
#### __[C#] Example 12: Scale and rotate content__

{{region cs-radpdfprocessing-editing-fixedcontenteditor_7}}
editor.Position.Scale(1.5, 0.5);
editor.Position.Rotate(10);
editor.DrawText("Image:");
editor.Position.Translate(0, 20);
fixedContentEditor.Position.Scale(1.5, 0.5);
fixedContentEditor.Position.Rotate(10);
fixedContentEditor.DrawText("Image:");
fixedContentEditor.Position.Translate(0, 20);
using (Stream stream = this.GetResourceStream("Telerik_logo.jpg"))
{
editor.DrawImage(stream, new Size(118, 28));
fixedContentEditor.DrawImage(stream, new Size(118, 28));
}
{{endregion}}

Expand Down
86 changes: 58 additions & 28 deletions libraries/radpdfprocessing/editing/radfixeddocumenteditor.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ __Example 1__ demonstrates how a RadFixedDocumentEditor instance can be created.
#### __[C#] Example 1: Create RadFixedDocumentEditor__

{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_0}}
RadFixedDocumentEditor editor = new RadFixedDocumentEditor(radFixedDocument);
RadFixedDocument radFixedDocument = new RadFixedDocument();
RadFixedDocumentEditor radFixedDocumentEditor = new RadFixedDocumentEditor(radFixedDocument);

//Use RadFixedDocumentEditor...

radFixedDocumentEditor.Dispose();
{{endregion}}

>__RadFixedDocumentEditor__ inherits from __IDisposable__ so it should be properly disposed when the document is created. Otherwise, some of the content may not be finished, i.e. it might not appear on the PDF document.
Expand All @@ -61,6 +66,10 @@ The section properties are responsible for the page size, margins and orientatio
* __Rotate180__: The page is rotated to 180°.
* __Rotate270__: The page is rotated to 270°.
{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_1}}
radFixedDocumentEditor.SectionProperties.PageSize = new Size(100,100);
radFixedDocumentEditor.SectionProperties.PageRotation = Telerik.Windows.Documents.Fixed.Model.Data.Rotation.Rotate90;
{{endregion}}

### Starting New Section

Expand All @@ -72,8 +81,8 @@ Adding an additional section is achieved with the __InsertSectionBreak()__ metho

#### __[C#] Example 2: Start a section__

{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_1}}
editor.InsertSectionBreak();
{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_2}}
radFixedDocumentEditor.InsertSectionBreak();
{{endregion}}


Expand All @@ -84,8 +93,8 @@ Adding an additional section is achieved with the __InsertSectionBreak()__ metho
All pages that have the same __SectionProperties__ are part of the current section. To start a new page, you can use the following code:

#### __[C#] Example 3: Start new page__
{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_2}}
editor.InsertPageBreak();
{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_3}}
radFixedDocumentEditor.InsertPageBreak();
{{endregion}}

## Paragraphs
Expand Down Expand Up @@ -120,6 +129,12 @@ Similar to the section properties, paragraph has its own properties that are res

* __ListLevel__: The list level the paragraph belongs to.

{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_4}}
radFixedDocumentEditor.ParagraphProperties.SpacingAfter = 10;
radFixedDocumentEditor.ParagraphProperties.LineSpacingType = HeightType.Auto;
adFixedDocumentEditor.ParagraphProperties.BackgroundColor = new RgbColor(0, 100, 0);
radFixedDocumentEditor.ParagraphProperties.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
{{endregion}}

### Starting New Paragraph

Expand All @@ -131,12 +146,11 @@ In order to start a new paragraph, use the code in __Example 4__.

#### __[C#] Example 4: Start a paragraph__

{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_3}}
editor.InsertParagraph();
{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_5}}
radFixedDocumentEditor.InsertParagraph();
{{endregion}}



The result of this method is that a new paragraph is started and it uses the current paragraph properties. Until a new paragraph is started, changes in the paragraph properties are not applied.


Expand Down Expand Up @@ -180,6 +194,15 @@ The character properties that are responsible for the look of the runs are liste

* __StrikethroughColor__: The color of the strikethrough.

{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_6}}
radFixedDocumentEditor.CharacterProperties.FontSize = 12;
radFixedDocumentEditor.CharacterProperties.Font = FontsRepository.Courier;
radFixedDocumentEditor.CharacterProperties.HighlightColor = new RgbColor(10, 100, 80);
radFixedDocumentEditor.CharacterProperties.BaselineAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.BaselineAlignment.Subscript;
radFixedDocumentEditor.CharacterProperties.UnderlinePattern = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.UnderlinePattern.Single;
{{endregion}}

>In order for the character properties to be respected, make sure to set them __before__ inserting the Run.
### Inserting a Run

Expand All @@ -188,9 +211,9 @@ There are a number of overloads that insert a run. The code snippet in __Example

#### __[C#] Example 5: Insert run__

{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_4}}
editor.InsertRun("text");
editor.InsertRun(fontFamily, "text");
{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_7}}
radFixedDocumentEditor.InsertRun("text");
radFixedDocumentEditor.InsertRun(new FontFamily("Helvetica"),"text");
{{endregion}}


Expand All @@ -204,12 +227,11 @@ The code in __Example 6__ inserts a new run and a line break after it.

#### __[C#] Example 6: Insert run and line break__

{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_5}}
editor.InsertLine("Line of text");
{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_8}}
radFixedDocumentEditor.InsertLine("Line of text");
{{endregion}}



### Images

Image inline is a combination of an [ImageSource]({%slug radpdfprocessing-model-imagesource%}) object and its desired size.
Expand All @@ -221,9 +243,10 @@ You can insert image inline using one of the following methods:

#### __[C#] Example 7: Insert image__

{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_6}}
editor.InsertImageInline(imageSource);
editor.InsertImageInline(imageSource, size);
{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_9}}
ImageSource imageSource = new ImageSource(new FileStream("image.jpeg", FileMode.Open));
radFixedDocumentEditor.InsertImageInline(imageSource);
radFixedDocumentEditor.InsertImageInline(imageSource, new Size(100, 100));
{{endregion}}

## Tables
Expand All @@ -233,8 +256,12 @@ The __Table__ class implements the __IBlockElement__ interface and an instance o

#### __[C#] Example 8: Insert table__

{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_7}}
editor.InsertTable(table);
{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_10}}
Table table = new Table();
TableRow firstRow = table.Rows.AddTableRow();
firstRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cellText");

radFixedDocumentEditor.InsertTable(table);
{{endregion}}

For more detailed information on tables, check the [Table]({%slug radpdfprocessing-editing-table%}) documentation article.
Expand All @@ -245,8 +272,11 @@ The [IBlockElement](https://docs.telerik.com/devtools/document-processing/api/Te

#### __[C#] Example 9: Insert Block element__

{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_8}}
editor.InsertBlock(blockElement);
{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_11}}
Block block = new Block();
block.InsertText("Text");

radFixedDocumentEditor.InsertBlock(block);
{{endregion}}


Expand All @@ -257,11 +287,11 @@ You can easily insert list items with __RadFixedDocumentEditor__. The first thin
The following code snippet shows how to add a new list to __RadFixedDocumentEditor’s ListCollection__ and after that insert a paragraph with the corresponding list properties:

#### __[C#] Example 10: Insert list__
{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_9}}
List list = editor.Lists.AddList(ListTemplateType.NumberedDefault);
editor.ParagraphProperties.ListId = list.Id;
editor.ParagraphProperties.ListLevel = 0;
editor.InsertParagraph();
{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_12}}
List list = radFixedDocumentEditor.Lists.AddList(ListTemplateType.NumberedDefault);
radFixedDocumentEditor.ParagraphProperties.ListId = list.Id;
radFixedDocumentEditor.ParagraphProperties.ListLevel = 0;
radFixedDocumentEditor.InsertParagraph();
{{endregion}}

More detailed information about lists is available in the [List documentation article]({%slug radpdfprocessing-editing-list%}).
Expand All @@ -271,8 +301,8 @@ More detailed information about lists is available in the [List documentation ar
With the RadFixedDocumentEditor class you can insert a Form (Form-XObject) element.

#### __[C#] Example 11: Insert a form__
{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_10}}
editor.InsertFormInline(formSource);
{{region cs-radpdfprocessing-editing-radfixeddocumenteditor_13}}
radFixedDocumentEditor.InsertFormInline(formSource);
{{endregion}}

There is an additional overload of InsertFormInline() that enables you to pass the size that should be used for the form.
Expand Down
Loading

0 comments on commit 943845b

Please sign in to comment.