Skip to content

Commit 5558782

Browse files
Dess move pdf code snippets (#650)
* replace code snippets with placeholders * Update bookmarks.md * Update search.md * replaced codeblock_ with snippet- * Update search.md * Update search.md * validate code snippet fix * completed renaming to editing folder * renamed up to radfixeddocument * Update checkboxfield.md * 81702 * Update radfixedpage.md * Update list.md
1 parent 5b89cd5 commit 5558782

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+181
-1915
lines changed

libraries/radpdfprocessing/concepts/clipping.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ __Example 1__ demonstrates how you can create a Clipping element and assign a __
2727

2828
#### __[C#] Example 1: Create clipping__
2929

30-
{{region cs-radpdfprocessing-concepts-clipping_0}}
31-
Clipping clipping = new Clipping();
32-
clipping.Clip = new RectangleGeometry(new Rect(5, 5, 50, 50));
33-
{{endregion}}
30+
<snippet id='pdf-clipping-geometry'/>
3431

3532

3633

@@ -44,10 +41,7 @@ __Example 2__ demonstrates how to clip an image using the Clipping created in __
4441

4542
#### __[C#] Example 2: Use clipping__
4643

47-
{{region cs-radpdfprocessing-concepts-clipping_1}}
48-
Image image = container.Content.AddImage(imageSource);
49-
image.Clipping = clipping;
50-
{{endregion}}
44+
<snippet id='pdf-image-clipping'/>
5145

5246

5347

libraries/radpdfprocessing/concepts/cmaps.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,7 @@ The **Telerik[.Windows].Documents.CMapUtils.dll** assembly provides a default im
2424
>To use this functionality, you must add a reference to the **Telerik[.Windows].Documents.CMapUtils.dll**.
2525
2626
#### [C#] Example 1: Register default CMapsProvider
27-
{{region radpdfprocessing-concepts-cmap_0}}
28-
// For .NET Framework
29-
Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.PredefinedCMapsProvider = new Telerik.Windows.Documents.CMapUtils.PredefinedCMapsProvider();
30-
31-
// For .NET Standard
32-
Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.PredefinedCMapsProvider = new Telerik.Documents.CMapUtils.PredefinedCMapsProvider();
33-
{{endregion}}
27+
<snippet id='pdf-cmaps'/>
3428

3529
After registering the **PredefinedCMapsProvider** class, you will be able to import any document containing a predefined CMap table.
3630

libraries/radpdfprocessing/concepts/colors-and-color-spaces.md

Lines changed: 10 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ __Example 1__ demonstrates how you can create an RgbColor and assign it as Fill
3434

3535
#### __[C#] Example 1: Create RgbColor__
3636

37-
{{region cs-radpdfprocessing-concepts-colors-and-color-spaces_0}}
38-
RgbColor magenta = new RgbColor(255, 0, 255);
39-
Path path = new Path();
40-
path.Fill = magenta;
41-
{{endregion}}
37+
<snippet id='pdf-create-rgb-color'/>
4238

4339
### CmykColor
4440

@@ -51,20 +47,7 @@ Represents a CMYK (cyan, magenta, yellow, key) color. The CmykColor class was in
5147

5248
#### Create CmykColor
5349

54-
```csharp
55-
RadFixedDocument document = new RadFixedDocument();
56-
RadFixedPage page = document.Pages.AddPage();
57-
FixedContentEditor containerEditor = new FixedContentEditor(page);
58-
59-
double c = 0.46;
60-
double m = 0.3;
61-
double y = 0.76;
62-
double k = 0.12;
63-
64-
CmykColor cmykColor = new CmykColor(c, m, y, k);
65-
containerEditor.GraphicProperties.FillColor = cmykColor;
66-
containerEditor.DrawRectangle(new Rect(10, 10, 48, 29));
67-
```
50+
<snippet id='pdf-create-cmyk-color'/>
6851

6952
![CMYK Color](images/cmyk-color.png)
7053

@@ -98,21 +81,13 @@ The __Gradient__ class is inherited by the following classes:
9881
9982
#### __[C#] Example 2: Create LinearGradient__
10083

101-
{{region cs-radpdfprocessing-concepts-colors-and-color-spaces_1}}
102-
FixedContentEditor containerEditor = new FixedContentEditor(container);
103-
104-
LinearGradient linearGradient = new LinearGradient(new Point(0, 0), new Point(30, 30));
105-
linearGradient.GradientStops.Add(new GradientStop(new RgbColor(0, 207, 0), 0));
106-
linearGradient.GradientStops.Add(new GradientStop(new RgbColor(0, 102, 204), 1));
107-
108-
containerEditor.GraphicProperties.FillColor = linearGradient;
109-
containerEditor.DrawRectangle(new Rect(10, 10, 48, 29));
110-
{{endregion}}
84+
<snippet id='pdf-create-linear-gradient'/>
11185

112-
The gradient created in __Example 2__ is shown in __Figure 1__.
86+
The gradient created in __Example 2__ is shown in __Figure 1__.
11387

114-
#### Figure 1: LinearGradient
115-
![Rad Pdf Processing Concepts Colors And Color Spaces 01](images/RadPdfProcessing_Concepts_Colors_And_Color_Spaces_01.png)
88+
#### Figure 1: LinearGradient
89+
90+
![Rad Pdf Processing Concepts Colors And Color Spaces 01](images/RadPdfProcessing_Concepts_Colors_And_Color_Spaces_01.png)
11691

11792
* __RadialGradient__: Defines a blend between two circles, optionally extended beyond the boundary circles by continuing the boundary colors. The __RadialGradient__ class exposes the following properties:
11893

@@ -124,16 +99,7 @@ The __Gradient__ class is inherited by the following classes:
12499

125100
#### __[C#] Example 3: Create RadialGradient__
126101

127-
{{region cs-radpdfprocessing-concepts-colors-and-color-spaces_3}}
128-
FixedContentEditor containerEditor = new FixedContentEditor(container);
129-
130-
RadialGradient radialGradient = new RadialGradient(new Point(40, 40), new Point(40, 40), 0, 30);
131-
radialGradient.GradientStops.Add(new GradientStop(new RgbColor(0, 207, 0), 0));
132-
radialGradient.GradientStops.Add(new GradientStop(new RgbColor(0, 102, 204), 1));
133-
134-
containerEditor.GraphicProperties.FillColor = radialGradient;
135-
containerEditor.DrawEllipse(new Point(40, 40), 30, 30);
136-
{{endregion}}
102+
<snippet id='pdf-create-linear-gradient'/>
137103

138104
The result from __Example 3__ is shown in __Figure 2__.
139105

@@ -177,18 +143,7 @@ Since the __TilingBase__ class implements the __IContentRootElement__ interface
177143

178144
#### __[C#] Example 4: Create tiling__
179145

180-
{{region cs-radpdfprocessing-concepts-colors-and-color-spaces_2}}
181-
FixedContentEditor containerEditor = new FixedContentEditor(container);
182-
183-
Tiling tiling = new Tiling(new Rect(0, 0, 10, 10));
184-
FixedContentEditor tilingEditor = new FixedContentEditor(tiling);
185-
tilingEditor.GraphicProperties.IsStroked = false;
186-
tilingEditor.GraphicProperties.FillColor = new RgbColor(128, 28, 43);
187-
tilingEditor.DrawRectangle(new Rect(2, 2, 5, 7));
188-
189-
containerEditor.GraphicProperties.FillColor = tiling;
190-
containerEditor.DrawCircle(new Point(30, 30), 20);
191-
{{endregion}}
146+
<snippet id='pdf-create-tiling'/>
192147

193148
The tiling created in __Example 4__ is shown in __Figure 3__.
194149

@@ -201,13 +156,7 @@ The tiling created in __Example 4__ is shown in __Figure 3__.
201156

202157
#### Create LabColor
203158

204-
```csharp
205-
double[] whitePoint = new double[3] { 1, 2, 3 };
206-
double[] range = new double[4] { 4, 5, 6, 7 };
207-
double[] expectedBlackPoint = new double[3] { 0, 0, 0 };
208-
209-
LabColor labColor = new LabColor(1, 2, 3, whitePoint, range);
210-
```
159+
<snippet id='pdf-create-lab-color'/>
211160

212161
## See Also
213162

libraries/radpdfprocessing/concepts/fonts.md

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,8 @@ There are 14 *Type 1* fonts, known as the standard 14 fonts, that are not embedd
8080
| ZapfDingbats|
8181

8282

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

85-
FontBase helvetica = FontsRepository.Helvetica;
86-
87-
{{endregion}}
84+
<snippet id='pdf-standard-font'/>
8885

8986
>tip These fonts, or their font metrics and suitable substitution fonts, must be available to the consumer application.
9087
@@ -93,11 +90,7 @@ FontsRepository will replace the provided standard font with the passed font dat
9390

9491
#### Replace a Standard Font
9592

96-
```csharp
97-
byte[] fontData = File.ReadAllBytes("Courier-font.ttf");
98-
FontsRepository.ReplaceStandardFont(StandardFontNames.Courier, fontData);
99-
100-
```
93+
<snippet id='pdf-replace-standard-font'/>
10194

10295
## Embedded Fonts
10396

@@ -113,49 +106,23 @@ __Example 1__ demonstrates how you can use the RegisterFont() method.
113106

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

116-
{{region cs-radpdfprocessing-concepts-fonts_1}}
117-
118-
// Read the font file
119-
byte[] fontData = File.ReadAllBytes("some-font.ttf");
120-
System.Windows.Media.FontFamily fontFamily = new System.Windows.Media.FontFamily("Some Font");
121-
122-
// Register the font
123-
Telerik.Windows.Documents.Fixed.Model.Fonts.FontsRepository.RegisterFont(fontFamily, System.Windows.FontStyles.Normal, System.Windows.FontWeights.Normal, fontData);
124-
{{endregion}}
109+
<snippet id='pdf-register-font-net-framework'/>
125110

126111
#### __[C#] Example 1: Register font in .NET Standard application__
127112

128-
{{region cs-radpdfprocessing-concepts-fonts_2}}
129-
130-
// Read the font file
131-
byte[] fontData = File.ReadAllBytes("some-font.ttf");
132-
Telerik.Documents.Core.Fonts.FontFamily fontFamily = new Telerik.Documents.Core.Fonts.FontFamily("Some Font");
133-
134-
// Register the font
135-
Telerik.Windows.Documents.Fixed.Model.Fonts.FontsRepository.RegisterFont(fontFamily, Telerik.Documents.Core.Fonts.FontStyles.Normal, Telerik.Documents.Core.Fonts.FontWeights.Normal, fontData);
136-
{{endregion}}
113+
<snippet id='pdf-register-font-net-standard'/>
137114

138115
### Creating a Font
139116

140117
>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.
141118
142-
{{region cs-radpdfprocessing-concepts-fonts_3}}
143-
144-
FontBase courier = FontsRepository.Courier;
145-
TextFragment textFragment = new TextFragment();
146-
textFragment.Font = courier;
147-
148-
{{endregion}}
119+
<snippet id='pdf-text-fragment-font'/>
149120

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

152-
153123
#### __[C#] Example 2: Create FontBase__
154124

155-
{{region cs-radpdfprocessing-concepts-fonts_4}}
156-
FontBase font;
157-
bool success = FontsRepository.TryCreateFont(fontFamily, fontStyle, fontWeight, out font);
158-
{{endregion}}
125+
<snippet id='pdf-bool-font-creation'/>
159126

160127
You can create fonts that are not explicitly registered. Creating a font that is not registered in the repository with the code from __Example 2__ tries to find the font from the ones installed on the machine.
161128

libraries/radpdfprocessing/concepts/geometry.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ __Example 1__ shows how to create a RectangleGeometry.
4747

4848
#### __[C#] Example 1: Create RectangleGeometry__
4949

50-
{{region cs-radpdfprocessing-concepts-geometry_0}}
51-
RectangleGeometry rectangleGeometry = new RectangleGeometry();
52-
rectangleGeometry.Rect = new Rect(10, 5, 400, 300);
53-
{{endregion}}
50+
<snippet id='pdf-create-rectangle-geometry'/>
5451

5552

5653

@@ -72,18 +69,7 @@ __Example 2__ shows how to create a PathGeometry, which consists of line segment
7269

7370
#### __[C#] Example 2: Create PathGeometry__
7471

75-
{{region cs-radpdfprocessing-concepts-geometry_1}}
76-
PathGeometry pathGeometry = new PathGeometry();
77-
PathFigure pathFigure = pathGeometry.Figures.AddPathFigure();
78-
pathFigure.StartPoint = new Point(5, 5);
79-
LineSegment lineSegment = pathFigure.Segments.AddLineSegment();
80-
lineSegment.Point = new Point(205, 5);
81-
BezierSegment bezierSegment = pathFigure.Segments.AddBezierSegment();
82-
bezierSegment.Point1 = new Point(105, 50);
83-
bezierSegment.Point2 = new Point(130, 105);
84-
bezierSegment.Point3 = new Point(100, 200);
85-
pathFigure.IsClosed = true;
86-
{{endregion}}
72+
<snippet id='pdf-create-path-geometry'/>
8773

8874

8975

libraries/radpdfprocessing/concepts/imagequality.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ In order to specify the default **ImageQuality** value when exporting to PDF, yo
3333

3434
#### __[C#] Example 1: Set a default value for all images in a document__
3535

36-
{{region cs-radpdfprocessing-concepts-imagequality_0}}
37-
PdfExportSettings settings = new PdfExportSettings();
38-
settings.ImageQuality = ImageQuality.Medium;
39-
{{endregion}}
36+
<snippet id='pdf-image-quality'/>
4037

4138
> `PdfExportSettings.ImageQuality` property doesn't affect the quality of the images imported from a PDF document. Such images are preserved using `EncodedImageData` (see [ImageQuality and EncodedImageData Class](#imagequality-and-encodedimagedata-class)). `PdfExportSettings.ImageQuality` only affects the export quality of images created using an image stream or a `BitmapSource`.
4239
@@ -46,9 +43,7 @@ If you need some particular image to be exported with a different **ImageQuality
4643

4744
#### __[C#] Example 2: Set the image quality of an image__
4845

49-
{{region cs-radpdfprocessing-concepts-imagequality_1}}
50-
ImageSource imageSource = new ImageSource(bitmap, ImageQuality.Medium);
51-
{{endregion}}
46+
<snippet id='pdf-image-source-quality'/>
5247

5348

5449
### ImageQuality and EncodedImageData Class

libraries/radpdfprocessing/concepts/position.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,7 @@ __Example 1__ shows how transformations can be appended.
6262

6363
#### __[C#] Example 1: Trasform MatrixPosition__
6464

65-
{{region cs-radpdfprocessing-concepts-position_0}}
66-
MatrixPosition matrixPosition = new MatrixPosition();
67-
matrixPosition.Translate(20, 20); // Translates the position by (20, 20)
68-
matrixPosition.Translate(30, 30); // Translates the position by (30, 30).
69-
{{endregion}}
65+
<snippet id='pdf-matrix-position'/>
7066

7167

7268

@@ -91,11 +87,7 @@ __Example 2__ shows how transformations overwrite the previous transformations o
9187

9288
#### __[C#] Example 2: Transform SimplePosition__
9389

94-
{{region cs-radpdfprocessing-concepts-position_1}}
95-
SimplePosition simplePosition = new SimplePosition();
96-
simplePosition.Translate(20, 20); // Translates the position by (20, 20).
97-
simplePosition.Translate(30, 30); // Translates the position by (30, 30) overwriting the previous translations.
98-
{{endregion}}
90+
<snippet id='pdf-simple-position'/>
9991

10092

10193

libraries/radpdfprocessing/cross-platform/images.md

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,8 @@ PdfProcessing comes with a default implementation for such resolver called `Imag
4343
>note View Implementation [Requirements](#requirements).
4444
4545
#### **[C#] Example 1: Set the default implementation of the ImagePropertiesResolver class**
46-
{{region cs-radpdfprocessing-cross-platform-images_0}}
47-
48-
Telerik.Documents.ImageUtils.ImagePropertiesResolver defaultImagePropertiesResolver = new Telerik.Documents.ImageUtils.ImagePropertiesResolver();
49-
Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.ImagePropertiesResolver = defaultImagePropertiesResolver;
50-
{{endregion}}
46+
47+
<snippet id='pdf-image-property-resolver'/>
5148

5249
### Custom Implementation for ImagePropertiesResolver
5350

@@ -72,49 +69,20 @@ The **Telerik.Documents.ImageUtils** assembly provides a default implementation
7269
>note View Implementation [Requirements](#requirements).
7370
7471
#### **[C#] Example 2: Set the default implementation of the JpegImageConverter class**
75-
{{region cs-radpdfprocessing-cross-platform_3}}
7672

77-
Telerik.Windows.Documents.Extensibility.JpegImageConverterBase defaultJpegImageConverter = new Telerik.Documents.ImageUtils.JpegImageConverter();
78-
Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.JpegImageConverter = defaultJpegImageConverter;
79-
{{endregion}}
73+
<snippet id='pdf-jpeg-image-converter'/>
8074

8175
### Custom Implementation for JpegImageConverter
8276

8377
The following example depends on the [Magick.NET](https://www.nuget.org/packages/Magick.NET-Q16-AnyCPU/) library to convert images to Jpeg format.
8478

8579
#### **[C#] Example 3: Create a custom implementation inheriting the JpegImageConverterBase abstract class**
86-
{{region cs-radpdfprocessing-cross-platform_2}}
87-
88-
internal class CustomJpegImageConverter : Telerik.Windows.Documents.Extensibility.JpegImageConverterBase
89-
{
90-
public override bool TryConvertToJpegImageData(byte[] imageData, ImageQuality imageQuality, out byte[] jpegImageData)
91-
{
92-
IMagickFormatInfo? formatInfo = MagickFormatInfo.Create(imageData);
93-
if (formatInfo != null && formatInfo.SupportsReading)
94-
{
95-
using (MagickImage magickImage = new MagickImage(imageData))
96-
{
97-
magickImage.Alpha(AlphaOption.Remove);
98-
magickImage.Quality = (int)imageQuality;
99-
100-
jpegImageData = magickImage.ToByteArray(MagickFormat.Jpeg);
101-
}
102-
103-
return true;
104-
}
105-
106-
jpegImageData = null;
107-
return false;
108-
}
109-
}
110-
{{endregion}}
80+
81+
<snippet id='pdf-custom-jpeg-converter'/>
11182

11283
#### **[C#] Example 4: Set the custom implementation to the JpegImageConverter property of the FixedExtensibilityManager**
113-
{{region cs-radpdfprocessing-cross-platform_3}}
114-
115-
JpegImageConverterBase customJpegImageConverter = new CustomJpegImageConverter();
116-
Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.JpegImageConverter = customJpegImageConverter;
117-
{{endregion}}
84+
85+
<snippet id='pdf-set-custom-image-converter'/>
11886

11987

12088
>note A complete SDK example of a custom implementation JpegImageConverterBase is available on our [GitHub repository](https://github.com/telerik/document-processing-sdk/tree/master/PdfProcessing/CustomJpegImageConverter).

0 commit comments

Comments
 (0)