Skip to content

Commit d1cc123

Browse files
authored
Merge branch 'master' into yoan/strikethrough
2 parents 91166bd + 02abc79 commit d1cc123

File tree

61 files changed

+1134
-79
lines changed

Some content is hidden

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

61 files changed

+1134
-79
lines changed

introduction.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,18 @@ The Telerik Document Processing libraries support the following file formats:
5555

5656
## Available Assemblies
5757

58-
>The Telerik Document Processing libraries are available in **.NET Framework** and **.NET Standard** (**.NET Core**) compatible versions. You can download the assemblies of these libraries from the following products:
58+
>The Telerik Document Processing libraries are available in **.NET Framework**, **.NET Core/.NET 6/.NET 8** (or newer) for Windows and **.NET Standard** compatible versions. You can download the assemblies of these libraries from the following products:
5959
>
6060
61-
|.NET Framework Products|.NET Standard/Core/5+ Products|
62-
|----|----|
63-
|[UI for ASP.NET MVC](https://www.telerik.com/aspnet-mvc)|[UI for Xamarin](https://www.telerik.com/xamarin-ui)|
64-
|[UI for ASP.NET AJAX](https://www.telerik.com/products/aspnet-ajax.aspx)|[UI for ASP.NET Core](https://www.telerik.com/aspnet-core-ui)|
65-
|[UI for WPF](https://www.telerik.com/products/wpf/overview.aspx)|[UI for Blazor](https://www.telerik.com/blazor-ui)|
66-
|[UI for WinForms](https://www.telerik.com/products/winforms.aspx)|[UI for WinUI](https://www.telerik.com/winui)|
67-
|[UI for Silverlight (discontinued)](https://www.telerik.com/products/silverlight/overview.aspx)|[UI for .NET MAUI](https://www.telerik.com/maui-ui)|
61+
|.NET Framework Products|.NET Core/.NET 6/ .NET 8 (or newer) *for Windows*|.NET Standard|
62+
|----|----|----|
63+
|[UI for ASP.NET MVC](https://www.telerik.com/aspnet-mvc)||[UI for Xamarin](https://www.telerik.com/xamarin-ui)|
64+
|[UI for ASP.NET AJAX](https://www.telerik.com/products/aspnet-ajax.aspx)||[UI for ASP.NET Core](https://www.telerik.com/aspnet-core-ui)|
65+
|[UI for WPF](https://www.telerik.com/products/wpf/overview.aspx)|[UI for WPF](https://www.telerik.com/products/wpf/overview.aspx)|[UI for Blazor](https://www.telerik.com/blazor-ui)|
66+
|[UI for WinForms](https://www.telerik.com/products/winforms.aspx)|[UI for WinForms](https://www.telerik.com/products/winforms.aspx)|[UI for WinUI](https://www.telerik.com/winui)|
67+
|[UI for Silverlight (discontinued)](https://www.telerik.com/products/silverlight/overview.aspx)||[UI for .NET MAUI](https://www.telerik.com/maui-ui)|
6868

69-
Both versions are available as [NuGet packages]({%slug installation-nuget-packages%}) but with different names. The assemblies for .NET Standard do not contain the word Windows in their name.
69+
All versions are available as [NuGet packages]({%slug installation-nuget-packages%}). The assemblies/packages for .NET Standard do not contain the word *Windows* in their name.
7070

7171
## Getting Started
7272

@@ -129,3 +129,4 @@ Thank you for your contribution to the Telerik Document Processing Libraries' Do
129129

130130
- [Document Processing Libraries Overview]({%slug getting-started%})
131131
- [First Steps in using Telerik Document Processing]({%slug getting-started-first-steps%})
132+
- [What Versions of Document Processing Libraries are Distributed with the Telerik Products]({%slug distribute-telerik-document-processing-libraries-net-versions%})
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
title: Adding a Barcode to a PDF Document using PdfProcessing and the WinForms BarcodeView
3+
description: Learn how to generate a barcode and incorporate it into a PDF document using Telerik products.
4+
type: how-to
5+
page_title: How to Add a Barcode to a PDF with PdfProcessing and the WinForms BarcodeView
6+
slug: add-barcode-to-pdf-telerik
7+
tags: radpdfprocessing, document processing, barcode, pdf, telerik reporting, winforms, barcodeview
8+
res_type: kb
9+
ticketid: 1657503
10+
---
11+
12+
## Environment
13+
14+
| Version | Product | Author |
15+
| --- | --- | ---- |
16+
| 2024.2.426| RadPdfProcessing |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)|
17+
18+
## Description
19+
20+
Learn how to generate a PDF document and add a barcode to it.
21+
22+
![Pdf with Barcodes](images/pdf-with-barcodes.png)
23+
24+
## Solution
25+
26+
To add a barcode to a PDF document, consider using the [WinForms BarcodeView](https://docs.telerik.com/devtools/winforms/controls/barcodeview/overview):
27+
28+
1\. First, [generate an image of the barcode](https://docs.telerik.com/devtools/winforms/controls/barcodeview/how-to/export-to-image)
29+
30+
2\. Then, add the [image to the PDF document]({%slug pdf-from-images-with-radfixeddocumenteditor%}). Here is a sample code snippet:
31+
32+
```csharp
33+
Telerik.WinControls.UI.Barcode.QRCode qrCode1 = new Telerik.WinControls.UI.Barcode.QRCode();
34+
RadBarcodeView radBarcodeView = new RadBarcodeView();
35+
radBarcodeView.BindingContext = new BindingContext();
36+
qrCode1.Version = 1;
37+
radBarcodeView.Symbology = qrCode1;
38+
radBarcodeView.Text = "radBarcodeView1";
39+
radBarcodeView.Value = "1234567";
40+
radBarcodeView.Invalidate();
41+
System.Drawing.Image img = radBarcodeView.ExportToImage(200, 200);
42+
string imageFilePath = "barcodeImage.png";
43+
img.Save(imageFilePath, System.Drawing.Imaging.ImageFormat.Png);
44+
45+
RadFixedDocument fixedDocument = new RadFixedDocument();
46+
RadFixedDocumentEditor documentEditor = new RadFixedDocumentEditor(fixedDocument);
47+
FileStream fileStream = new FileStream(imageFilePath, FileMode.Open);
48+
Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource _imageSource = new Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource(fileStream);
49+
documentEditor.InsertImageInline(_imageSource);
50+
documentEditor.InsertLineBreak();
51+
documentEditor.Dispose();
52+
PdfFormatProvider provider = new PdfFormatProvider();
53+
string outputFilePath = "output.pdf";
54+
File.Delete(outputFilePath);
55+
using (Stream output = File.OpenWrite(outputFilePath))
56+
{
57+
provider.Export(fixedDocument, output);
58+
}
59+
Process.Start(new ProcessStartInfo() { FileName = outputFilePath, UseShellExecute = true });
60+
```
61+
62+
## Notes
63+
64+
- The WinForms BarcodeView method is suitable for applications where a barcode image can be generated and saved before adding it to the PDF: [Generating a Bar Code Image outside WinForms](https://docs.telerik.com/devtools/winforms/knowledge-base/gridview-generating-barcode-image-non-winforms).
65+
66+
## See Also
67+
68+
- [RadPdfProcessing Documentation]({%slug radpdfprocessing-overview%})
69+
- [WinForms BarcodeView](https://docs.telerik.com/devtools/winforms/controls/barcodeview/overview)
70+
- [Exporting BarcodeView to Image](https://docs.telerik.com/devtools/winforms/controls/barcodeview/how-to/export-to-image)
71+
- [Generating a Barcode Image outside WinForms](https://docs.telerik.com/devtools/winforms/knowledge-base/gridview-generating-barcode-image-non-winforms)
72+
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
title: Adding Images with a Shadow in PDF Documents
3+
description: Learn how to add a shadow effect when inserting images into PDF documents using RadPdfProcessing.
4+
type: how-to
5+
page_title: How to Simulate Shadow Effects for Images in PDFs with RadPdfProcessing
6+
slug: add-shadow-image-radpdfprocessing
7+
tags: radpdfprocessing, document processing, image, shadow, insertimage, path, geometry
8+
res_type: kb
9+
ticketid: 1655064
10+
---
11+
12+
## Environment
13+
14+
| Version | Product | Author |
15+
| --- | --- | ---- |
16+
| 2024.2.426| RadPdfProcessing |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)|
17+
18+
## Description
19+
20+
When inserting an image into a PDF document using the [Block.InsertImage](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/editing/block#inserting-image) method, you might want to add a shadow effect to enhance its appearance. [RadPdfProcessing](%slug radpdfprocessing-overview%) provides functionalities to draw paths and geometries, enabling the simulation of shadows around images. This KB article demonstrates how to add a shadow to an image in a PDF document.
21+
22+
## Solution
23+
24+
To add a shadow to an image, utilize [paths]({%slug radpdfprocessing-model-path%}) with specific [geometries]({%slug radpdfprocessing-concepts-geometry%}) to simulate the shadow effect. The following example outlines the necessary steps to insert an image and draw a shadow around it using RadPdfProcessing:
25+
26+
1. **Prepare the environment**: Ensure that [ImagePropertiesResolver](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/cross-platform/images#imagepropertiesresolver) and [JpegImageConverter](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/cross-platform/images#jpegimageconverter) are set for cross-platform image scenarios. Refer to the RadPdfProcessing documentation on [cross-platform image handling]({%slug radpdfprocessing-cross-platform-images%}).
27+
28+
2. **Insert the image**: Use the `Block.InsertImage` method to insert the image into a block.
29+
30+
3. **Draw the shadow**: Create a `RectangleGeometry` around the image's location with an offset to simulate the shadow effect. Use a dark color for the shadow and adjust its opacity as needed.
31+
32+
4. **Export the PDF document**: Use the [PdfFormatProvider]({%slug radpdfprocessing-formats-and-conversion-pdf-pdfformatprovider%}) to export the document to a PDF file.
33+
34+
```csharp
35+
public static Padding pageMarginsValue = new Telerik.Windows.Documents.Primitives.Padding(
36+
Unit.MmToDip(20), //left
37+
Unit.MmToDip(20), //top
38+
Unit.MmToDip(0), //right
39+
Unit.MmToDip(0)); //bottom
40+
41+
static void Main(string[] args)
42+
{
43+
// Setup the environment for image handling
44+
Telerik.Documents.ImageUtils.ImagePropertiesResolver defaultImagePropertiesResolver = new Telerik.Documents.ImageUtils.ImagePropertiesResolver();
45+
Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.ImagePropertiesResolver = defaultImagePropertiesResolver;
46+
Telerik.Windows.Documents.Extensibility.JpegImageConverterBase defaultJpegImageConverter = new Telerik.Documents.ImageUtils.JpegImageConverter();
47+
Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.JpegImageConverter = defaultJpegImageConverter;
48+
49+
RadFixedDocument fixedDocument = new RadFixedDocument();
50+
RadFixedPage fixedPage = fixedDocument.Pages.AddPage();
51+
FixedContentEditor fixedContentEditor = new FixedContentEditor(fixedPage);
52+
53+
using (Stream imageStream = File.OpenRead("ninja.png"))
54+
{
55+
Block imageBlock = new Block();
56+
imageBlock.SpacingAfter = 0;
57+
imageBlock.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
58+
Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource _imageSource =
59+
new Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource(imageStream);
60+
imageBlock.InsertImage(_imageSource);
61+
Size imageBlockDesiredSize = imageBlock.Measure();
62+
int shadowWidth = 10;
63+
64+
// DrawShadow
65+
RectangleGeometry rectangleGeometry = new RectangleGeometry();
66+
rectangleGeometry.Rect = new Rect(pageMarginsValue.Left + shadowWidth, pageMarginsValue.Top + shadowWidth, imageBlockDesiredSize.Width, imageBlockDesiredSize.Height);
67+
Telerik.Windows.Documents.Fixed.Model.Graphics.Path path = fixedPage.Content.AddPath();
68+
path.IsFilled = true;
69+
path.IsStroked = false;
70+
RgbColor shadowColor = new RgbColor(80, 0, 0, 0);
71+
path.Fill = shadowColor;
72+
path.Geometry = rectangleGeometry;
73+
74+
fixedContentEditor.DrawBlock(imageBlock);
75+
76+
// Export the document
77+
PdfFormatProvider provider = new PdfFormatProvider();
78+
string outputFilePath = @"sample.pdf";
79+
using (Stream output = File.OpenWrite(outputFilePath))
80+
{
81+
provider.Export(fixedDocument, output);
82+
}
83+
Process.Start(new ProcessStartInfo() { FileName = outputFilePath, UseShellExecute = true });
84+
}
85+
}
86+
```
87+
![Image Shadon in PDF](images/image-shadow-pdf.png)
88+
89+
Adjust the shadow's size, color, and opacity according to your requirements. This approach can be customized to fit specific needs or visual styles.
90+
91+
## Notes
92+
93+
- The provided example is a basic approach to simulating a shadow and might not cover all use cases.
94+
- Experiment with different geometry shapes and colors to achieve the desired shadow effect.
95+
96+
## See Also
97+
98+
- [RadPdfProcessing Documentation]({%slug radpdfprocessing-overview%})
99+
- [Drawing Geometries in PDF Documents](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/editing/fixedcontenteditor#inserting-geometries)
100+
- [Handling Images in Cross-Platform Scenarios]({%slug radpdfprocessing-cross-platform-images%})
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
title: Adding a Watermark to PDF Files Using RadPdfProcessing
3+
description: Learn how to add custom watermarks to PDF documents using the RadPdfProcessing library.
4+
type: how-to
5+
page_title: How to Add Watermarks to PDF Documents with RadPdfProcessing
6+
slug: add-watermark-pdf-radpdfprocessing
7+
tags: radpdfprocessing, document processing, watermark, pdf, text watermark
8+
res_type: kb
9+
ticketid: 1653970
10+
---
11+
12+
## Environment
13+
14+
| Version | Product | Author |
15+
| --- | --- | ---- |
16+
| 2024.2.426| RadPdfProcessing |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)|
17+
18+
## Description
19+
20+
This KB article demonstrates how to add a text watermark across all pages of a PDF document using RadPdfProcessing.
21+
22+
## Solution
23+
24+
To add a watermark to PDF pages using RadPdfProcessing, follow these steps:
25+
26+
1. Import the PDF document using [PdfFormatProvider]({%slug radpdfprocessing-formats-and-conversion-pdf-pdfformatprovider%}).
27+
2. Iterate through each page of the document.
28+
3. Use [FixedContentEditor]({%slug radpdfprocessing-editing-fixedcontenteditor%}) to add a watermark text block to each page.
29+
4. Customize the watermark's text properties, color, and position.
30+
5. [Export](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/formats-and-conversion/pdf/pdfformatprovider/pdfformatprovider#export) the document with watermarks back to a PDF file.
31+
32+
Here is a complete code snippet demonstrating these steps:
33+
34+
```csharp
35+
static void Main(string[] args)
36+
{
37+
string fileName = "sample.pdf";
38+
PdfFormatProvider provider = new PdfFormatProvider();
39+
RadFixedDocument document = provider.Import(File.ReadAllBytes(fileName));
40+
41+
foreach (RadFixedPage page in document.Pages)
42+
{
43+
AddWatermarkText(page, "Watermark text!", 100);
44+
}
45+
46+
string exportFileName = "testWatermarks.pdf";
47+
File.Delete(exportFileName);
48+
49+
File.WriteAllBytes(exportFileName, new PdfFormatProvider().Export(document));
50+
ProcessStartInfo psi = new ProcessStartInfo()
51+
{
52+
FileName = exportFileName,
53+
UseShellExecute = true
54+
};
55+
Process.Start(psi);
56+
}
57+
58+
private static void AddWatermarkText(RadFixedPage page, string text, byte transparency)
59+
{
60+
FixedContentEditor editor = new FixedContentEditor(page);
61+
62+
Block block = new Block();
63+
block.TextProperties.FontSize = 80;
64+
block.TextProperties.TrySetFont(new FontFamily("Arial"), FontStyles.Normal, FontWeights.Bold);
65+
block.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
66+
block.GraphicProperties.FillColor = new RgbColor(transparency, 255, 0, 0);
67+
block.InsertText(text);
68+
69+
double angle = -45;
70+
editor.Position.Rotate(angle);
71+
editor.Position.Translate(0, page.Size.Width);
72+
editor.DrawBlock(block, new Size(page.Size.Width / Math.Abs(Math.Sin(angle)), double.MaxValue));
73+
}
74+
```
75+
76+
![Pdf Watermark](images/pdf-watermark.png)
77+
78+
## See Also
79+
80+
- [FixedContentEditor]({%slug radpdfprocessing-editing-fixedcontenteditor%})
81+
- [SDK Example: Add Watermark](https://github.com/telerik/document-processing-sdk/blob/master/PdfProcessing/AddWatermark/Program.cs)
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
title: Changing Checkbox State in Word Templates with RadWordsProcessing
3+
description: Learn how to programmatically change the state of a checkbox in a Word document template using RadWordsProcessing.
4+
type: how-to
5+
page_title: How to Programmatically Modify Checkbox States in Word Document Templates Using RadWordsProcessing
6+
slug: change-checkbox-state-radwordsprocessing
7+
tags: radwordsprocessing, document processing, checkbox, word, template
8+
res_type: kb
9+
ticketid: 1656247
10+
---
11+
12+
## Environment
13+
14+
|Product Version|Product|Author|
15+
|----|----|----|
16+
|2024.2.426|RadWordsProcessing|[Yoan Karamanov](https://www.telerik.com/blogs/author/yoan-karamanov)|
17+
18+
## Description
19+
20+
When working with Word templates that include checkboxes as content controls, you may need to change the state of a checkbox based on certain conditions. This KB article provides a method to programmatically check or uncheck a checkbox using the RadWordsProcessing library.
21+
22+
This KB article also answers the following questions:
23+
- How can I programmatically check a checkbox in a Word document?
24+
- How do I modify the state of a checkbox in a Word template?
25+
- What is the method to change checkbox states in Word documents using C#?
26+
27+
## Solution
28+
29+
To change the state of a checkbox in a Word document, follow these steps:
30+
31+
1. Identify the content control that represents the checkbox.
32+
2. Change the checkbox's state to either checked or unchecked.
33+
3. Update the visual representation of the checkbox accordingly.
34+
35+
Below is a method that demonstrates how to achieve this:
36+
37+
```csharp
38+
private static void ChangeCheckboxState(SdtRangeStart sdt)
39+
{
40+
if (sdt == null || sdt.SdtProperties.Type != SdtType.CheckBox)
41+
{
42+
return;
43+
}
44+
45+
// Get the paragraph that is parent of the checkbox
46+
Paragraph paragraph = sdt.Paragraph;
47+
48+
// Get the index of the SDT start in the paragraph's child collection
49+
int index = paragraph.Inlines.IndexOf(sdt);
50+
51+
// Get the Run that represents the checkbox' value
52+
Run checkBoxValue = paragraph.Inlines[index + 1] as Run;
53+
CheckBoxProperties properties = (CheckBoxProperties)sdt.SdtProperties;
54+
if (!properties.Checked.HasValue || !properties.Checked.Value)
55+
{
56+
properties.Checked = true;
57+
58+
if (checkBoxValue != null)
59+
{
60+
checkBoxValue.Properties.FontFamily.LocalValue = new ThemableFontFamily(properties.CheckedState.Font);
61+
checkBoxValue.Text = ((char)properties.CheckedState.CharacterCode).ToString();
62+
}
63+
}
64+
else
65+
{
66+
properties.Checked = false;
67+
68+
if (checkBoxValue != null)
69+
{
70+
checkBoxValue.Properties.FontFamily.LocalValue = new ThemableFontFamily(properties.UncheckedState.Font);
71+
checkBoxValue.Text = ((char)properties.UncheckedState.CharacterCode).ToString();
72+
}
73+
}
74+
}
75+
```
76+
77+
To apply this method, iterate through the content controls in your document, and call `ChangeCheckboxState` for each checkbox you wish to modify. Alternatively, get the first SdtRangeStart and update its state:
78+
79+
```csharp
80+
SdtRangeStart stdStart = document.EnumerateChildrenOfType<SdtRangeStart>().First();
81+
ChangeCheckboxState(stdStart);
82+
```
83+
84+
85+
## Notes
86+
87+
- Ensure that you have identified the correct content control by checking its tag or other properties.
88+
- The visual representation of the checkbox is determined by the font family and character code specified in the `CheckedState` and `UncheckedState` of the `CheckBoxProperties`.
89+
90+
## See Also
91+
92+
- [Working with Content Controls]({%slug wordsprocessing-model-working-with-content-controls%})
93+
- [Content Controls (Structured Document Tags)]({%slug wordsprocessing-model-content-controls%})

0 commit comments

Comments
 (0)