Skip to content
Merged
10 changes: 2 additions & 8 deletions libraries/radpdfprocessing/concepts/clipping.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ __Example 1__ demonstrates how you can create a Clipping element and assign a __

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

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



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

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

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



Expand Down
8 changes: 1 addition & 7 deletions libraries/radpdfprocessing/concepts/cmaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ The **Telerik[.Windows].Documents.CMapUtils.dll** assembly provides a default im
>To use this functionality, you must add a reference to the **Telerik[.Windows].Documents.CMapUtils.dll**.

#### [C#] Example 1: Register default CMapsProvider
{{region radpdfprocessing-concepts-cmap_0}}
// For .NET Framework
Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.PredefinedCMapsProvider = new Telerik.Windows.Documents.CMapUtils.PredefinedCMapsProvider();

// For .NET Standard
Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.PredefinedCMapsProvider = new Telerik.Documents.CMapUtils.PredefinedCMapsProvider();
{{endregion}}
<snippet id='pdf-cmaps'/>

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

Expand Down
71 changes: 10 additions & 61 deletions libraries/radpdfprocessing/concepts/colors-and-color-spaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ __Example 1__ demonstrates how you can create an RgbColor and assign it as Fill

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

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

### CmykColor

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

#### Create CmykColor

```csharp
RadFixedDocument document = new RadFixedDocument();
RadFixedPage page = document.Pages.AddPage();
FixedContentEditor containerEditor = new FixedContentEditor(page);

double c = 0.46;
double m = 0.3;
double y = 0.76;
double k = 0.12;

CmykColor cmykColor = new CmykColor(c, m, y, k);
containerEditor.GraphicProperties.FillColor = cmykColor;
containerEditor.DrawRectangle(new Rect(10, 10, 48, 29));
```
<snippet id='pdf-create-cmyk-color'/>

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

Expand Down Expand Up @@ -98,21 +81,13 @@ The __Gradient__ class is inherited by the following classes:

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

{{region cs-radpdfprocessing-concepts-colors-and-color-spaces_1}}
FixedContentEditor containerEditor = new FixedContentEditor(container);

LinearGradient linearGradient = new LinearGradient(new Point(0, 0), new Point(30, 30));
linearGradient.GradientStops.Add(new GradientStop(new RgbColor(0, 207, 0), 0));
linearGradient.GradientStops.Add(new GradientStop(new RgbColor(0, 102, 204), 1));

containerEditor.GraphicProperties.FillColor = linearGradient;
containerEditor.DrawRectangle(new Rect(10, 10, 48, 29));
{{endregion}}
<snippet id='pdf-create-linear-gradient'/>

The gradient created in __Example 2__ is shown in __Figure 1__.
The gradient created in __Example 2__ is shown in __Figure 1__.

#### Figure 1: LinearGradient
![Rad Pdf Processing Concepts Colors And Color Spaces 01](images/RadPdfProcessing_Concepts_Colors_And_Color_Spaces_01.png)
#### Figure 1: LinearGradient

![Rad Pdf Processing Concepts Colors And Color Spaces 01](images/RadPdfProcessing_Concepts_Colors_And_Color_Spaces_01.png)

* __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:

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

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

{{region cs-radpdfprocessing-concepts-colors-and-color-spaces_3}}
FixedContentEditor containerEditor = new FixedContentEditor(container);

RadialGradient radialGradient = new RadialGradient(new Point(40, 40), new Point(40, 40), 0, 30);
radialGradient.GradientStops.Add(new GradientStop(new RgbColor(0, 207, 0), 0));
radialGradient.GradientStops.Add(new GradientStop(new RgbColor(0, 102, 204), 1));

containerEditor.GraphicProperties.FillColor = radialGradient;
containerEditor.DrawEllipse(new Point(40, 40), 30, 30);
{{endregion}}
<snippet id='pdf-create-linear-gradient'/>

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

Expand Down Expand Up @@ -177,18 +143,7 @@ Since the __TilingBase__ class implements the __IContentRootElement__ interface

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

{{region cs-radpdfprocessing-concepts-colors-and-color-spaces_2}}
FixedContentEditor containerEditor = new FixedContentEditor(container);

Tiling tiling = new Tiling(new Rect(0, 0, 10, 10));
FixedContentEditor tilingEditor = new FixedContentEditor(tiling);
tilingEditor.GraphicProperties.IsStroked = false;
tilingEditor.GraphicProperties.FillColor = new RgbColor(128, 28, 43);
tilingEditor.DrawRectangle(new Rect(2, 2, 5, 7));

containerEditor.GraphicProperties.FillColor = tiling;
containerEditor.DrawCircle(new Point(30, 30), 20);
{{endregion}}
<snippet id='pdf-create-tiling'/>

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

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

#### Create LabColor

```csharp
double[] whitePoint = new double[3] { 1, 2, 3 };
double[] range = new double[4] { 4, 5, 6, 7 };
double[] expectedBlackPoint = new double[3] { 0, 0, 0 };

LabColor labColor = new LabColor(1, 2, 3, whitePoint, range);
```
<snippet id='pdf-create-lab-color'/>

## See Also

Expand Down
45 changes: 6 additions & 39 deletions libraries/radpdfprocessing/concepts/fonts.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,8 @@ There are 14 *Type 1* fonts, known as the standard 14 fonts, that are not embedd
| ZapfDingbats|


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

FontBase helvetica = FontsRepository.Helvetica;

{{endregion}}
<snippet id='pdf-standard-font'/>

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

Expand All @@ -93,11 +90,7 @@ FontsRepository will replace the provided standard font with the passed font dat

#### Replace a Standard Font

```csharp
byte[] fontData = File.ReadAllBytes("Courier-font.ttf");
FontsRepository.ReplaceStandardFont(StandardFontNames.Courier, fontData);

```
<snippet id='pdf-replace-standard-font'/>

## Embedded Fonts

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

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

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

// Read the font file
byte[] fontData = File.ReadAllBytes("some-font.ttf");
System.Windows.Media.FontFamily fontFamily = new System.Windows.Media.FontFamily("Some Font");

// Register the font
Telerik.Windows.Documents.Fixed.Model.Fonts.FontsRepository.RegisterFont(fontFamily, System.Windows.FontStyles.Normal, System.Windows.FontWeights.Normal, fontData);
{{endregion}}
<snippet id='pdf-register-font-net-framework'/>

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

{{region cs-radpdfprocessing-concepts-fonts_2}}

// Read the font file
byte[] fontData = File.ReadAllBytes("some-font.ttf");
Telerik.Documents.Core.Fonts.FontFamily fontFamily = new Telerik.Documents.Core.Fonts.FontFamily("Some Font");

// Register the font
Telerik.Windows.Documents.Fixed.Model.Fonts.FontsRepository.RegisterFont(fontFamily, Telerik.Documents.Core.Fonts.FontStyles.Normal, Telerik.Documents.Core.Fonts.FontWeights.Normal, fontData);
{{endregion}}
<snippet id='pdf-register-font-net-standard'/>

### Creating a Font

>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}}
<snippet id='pdf-text-fragment-font'/>

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


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

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

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.

Expand Down
18 changes: 2 additions & 16 deletions libraries/radpdfprocessing/concepts/geometry.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ __Example 1__ shows how to create a RectangleGeometry.

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

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



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

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

{{region cs-radpdfprocessing-concepts-geometry_1}}
PathGeometry pathGeometry = new PathGeometry();
PathFigure pathFigure = pathGeometry.Figures.AddPathFigure();
pathFigure.StartPoint = new Point(5, 5);
LineSegment lineSegment = pathFigure.Segments.AddLineSegment();
lineSegment.Point = new Point(205, 5);
BezierSegment bezierSegment = pathFigure.Segments.AddBezierSegment();
bezierSegment.Point1 = new Point(105, 50);
bezierSegment.Point2 = new Point(130, 105);
bezierSegment.Point3 = new Point(100, 200);
pathFigure.IsClosed = true;
{{endregion}}
<snippet id='pdf-create-path-geometry'/>



Expand Down
9 changes: 2 additions & 7 deletions libraries/radpdfprocessing/concepts/imagequality.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ In order to specify the default **ImageQuality** value when exporting to PDF, yo

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

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

> `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`.

Expand All @@ -46,9 +43,7 @@ If you need some particular image to be exported with a different **ImageQuality

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

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


### ImageQuality and EncodedImageData Class
Expand Down
12 changes: 2 additions & 10 deletions libraries/radpdfprocessing/concepts/position.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ __Example 1__ shows how transformations can be appended.

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

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



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

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

{{region cs-radpdfprocessing-concepts-position_1}}
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.
{{endregion}}
<snippet id='pdf-simple-position'/>



Expand Down
46 changes: 7 additions & 39 deletions libraries/radpdfprocessing/cross-platform/images.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@ PdfProcessing comes with a default implementation for such resolver called `Imag
>note View Implementation [Requirements](#requirements).

#### **[C#] Example 1: Set the default implementation of the ImagePropertiesResolver class**
{{region cs-radpdfprocessing-cross-platform-images_0}}

Telerik.Documents.ImageUtils.ImagePropertiesResolver defaultImagePropertiesResolver = new Telerik.Documents.ImageUtils.ImagePropertiesResolver();
Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.ImagePropertiesResolver = defaultImagePropertiesResolver;
{{endregion}}

<snippet id='pdf-image-property-resolver'/>

### Custom Implementation for ImagePropertiesResolver

Expand All @@ -72,49 +69,20 @@ The **Telerik.Documents.ImageUtils** assembly provides a default implementation
>note View Implementation [Requirements](#requirements).

#### **[C#] Example 2: Set the default implementation of the JpegImageConverter class**
{{region cs-radpdfprocessing-cross-platform_3}}

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

### Custom Implementation for JpegImageConverter

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

#### **[C#] Example 3: Create a custom implementation inheriting the JpegImageConverterBase abstract class**
{{region cs-radpdfprocessing-cross-platform_2}}

internal class CustomJpegImageConverter : Telerik.Windows.Documents.Extensibility.JpegImageConverterBase
{
public override bool TryConvertToJpegImageData(byte[] imageData, ImageQuality imageQuality, out byte[] jpegImageData)
{
IMagickFormatInfo? formatInfo = MagickFormatInfo.Create(imageData);
if (formatInfo != null && formatInfo.SupportsReading)
{
using (MagickImage magickImage = new MagickImage(imageData))
{
magickImage.Alpha(AlphaOption.Remove);
magickImage.Quality = (int)imageQuality;

jpegImageData = magickImage.ToByteArray(MagickFormat.Jpeg);
}

return true;
}

jpegImageData = null;
return false;
}
}
{{endregion}}

<snippet id='pdf-custom-jpeg-converter'/>

#### **[C#] Example 4: Set the custom implementation to the JpegImageConverter property of the FixedExtensibilityManager**
{{region cs-radpdfprocessing-cross-platform_3}}

JpegImageConverterBase customJpegImageConverter = new CustomJpegImageConverter();
Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.JpegImageConverter = customJpegImageConverter;
{{endregion}}

<snippet id='pdf-set-custom-image-converter'/>


>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).
Expand Down
Loading