Skip to content

Commit dceb258

Browse files
Merge branch 'master' into new-kb-add-watermark-pdf-radpdfprocessing-148c1282b51b44c38dd649ca2925a3e3
2 parents 8117e14 + 0d0baa3 commit dceb258

File tree

47 files changed

+1141
-29
lines changed

Some content is hidden

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

47 files changed

+1141
-29
lines changed

getting-started/Installation/nuget-packages.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ Telerik provides NuGet packages with the assemblies for all five Document Proces
1414

1515
If your workflow relies on NuGet for package management, you can take advantage of the packages that we describe in this article. There is no need to download and install the Document Processing libraries by using other methods.
1616

17-
> The improved Telerik NuGet v3 is now available at https://nuget.telerik.com/v3/index.json. The new v3 API is faster, lighter, and reduces the number of requests from NuGet clients. The old https://nuget.telerik.com/nuget server will be deprecated and we encourage our clients to switch to the v3 API and use https://nuget.telerik.com/v3/index.json to access it.
18-
1917
>caution The old **https://nuget.telerik.com/nuget** server is deprecated and we encourage our clients to switch to the v3 API. The new v3 API is faster, lighter, and reduces the number of requests from NuGet clients. The **NuGet v2** server at https://nuget.telerik.com/nuget will be sunset in **November 2024**. The new v3 protocol offers faster package searches and restores, improved security, and more reliable infrastructure. To redirect your feed to the NuGet v3 protocol, all you have to do is to change your NuGet package source URL to https://nuget.telerik.com/v3/index.json.
2018
2119
#### This article contains the following sections:

getting-started/first-steps.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ Since we distribute Telerik Document Processing libraries as an addition to seve
1919

2020
>tipRegardless of the Telerik UI components suite that you use, you can always get the Document Processing assemblies as NuGet packages from the [Telerik NuGet server]({%slug installation-nuget-packages%}).
2121
22-
> The improved Telerik NuGet v3 is now available at **https://nuget.telerik.com/v3/index.json**. The new v3 API is faster, lighter, and reduces the number of requests from NuGet clients. The old https://nuget.telerik.com/nuget server will be deprecated and we encourage our clients to switch to the v3 API and use https://nuget.telerik.com/v3/index.json to access it.
23-
2422
>caution The old **https://nuget.telerik.com/nuget** server is deprecated and we encourage our clients to switch to the v3 API. The new v3 API is faster, lighter, and reduces the number of requests from NuGet clients. The **NuGet v2** server at https://nuget.telerik.com/nuget will be sunset in **November 2024**. The new v3 protocol offers faster package searches and restores, improved security, and more reliable infrastructure. To redirect your feed to the NuGet v3 protocol, all you have to do is to change your NuGet package source URL to https://nuget.telerik.com/v3/index.json.
2523
2624
| UI Components suite | Installation instructions | Default location of the Document Processing assemblies |
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%})

knowledge-base/convert-tiff-to-pdf-radpdfprocessing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,6 @@ This approach ensures the TIFF images are converted to PDF format without any pa
110110

111111
## See Also
112112

113-
- [RadPdfProcessing Documentation]({%slug radpdfprocessing-overview%}})
114-
- [How to Generate a PDF Document from Images with FixedContentEditor]({%slug pdf-from-images-with-fixedcontenteditor%}})
115-
- [How to Generate a PDF Document from Images with RadFixedDocumentEditor]({%slug pdf-from-images-with-radfixeddocumenteditor%}})
113+
- [RadPdfProcessing Documentation]({%slug radpdfprocessing-overview%})
114+
- [How to Generate a PDF Document from Images with FixedContentEditor]({%slug pdf-from-images-with-fixedcontenteditor%})
115+
- [How to Generate a PDF Document from Images with RadFixedDocumentEditor]({%slug pdf-from-images-with-radfixeddocumenteditor%})
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: Creating a Cropped PDF from an Existing PDF Page Using RadPdfProcessing
3+
description: Learn how to generate a new PDF document by cropping a page from an existing PDF using RadPdfProcessing.
4+
type: how-to
5+
page_title: How to Crop a Page from an Existing PDF and Create a New Document with RadPdfProcessing
6+
slug: create-cropped-pdf-radpdfprocessing
7+
tags: radpdfprocessing, document processing, pdf, crop, pdfstreamwriter
8+
res_type: kb
9+
ticketid: 1653594
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 working with PDF documents, you might encounter scenarios where you need to extract and crop a specific page to create a new PDF document. This article demonstrates how to use [RadPdfProcessing]({%slug radpdfprocessing-overview%}) to crop a page from an existing PDF and save the cropped content as a new PDF document.
21+
22+
## Solution
23+
24+
To create a new PDF document from a cropped page of an existing PDF, follow these steps:
25+
26+
1. **Extract the desired page from the original PDF document.** Use the [PdfFileSource]({%slug radpdfprocessing-formats-and-conversion-pdf-pdfstreamwriter-pdffilesource%}) class to access the pages of the original PDF.
27+
28+
2. **Create a new PDF document with the extracted page.** Utilize the [PdfStreamWriter]({%slug radpdfprocessing-formats-and-conversion-pdf-pdfstreamwriter-overview%}) class to write the extracted page into a new PDF document.
29+
30+
3. **Crop the content of the newly created PDF.** Modify the `CropBox` of the `RadFixedPage` to specify the cropped area.
31+
32+
4. **Export the cropped document as a new PDF file.**
33+
34+
Here's a complete code snippet illustrating the process:
35+
36+
```csharp
37+
private static void CreateCroppedPagePDF()
38+
{
39+
string originalFilePath = @"WinForms PdfViewer.pdf";
40+
int pageIndex = 3;
41+
string outputPageFilePath = @"..\..\page3.pdf";
42+
File.Delete(outputPageFilePath);
43+
using (PdfFileSource fileToSplit = new PdfFileSource(File.OpenRead(originalFilePath)))
44+
{
45+
PdfPageSource page = fileToSplit.Pages[pageIndex];
46+
47+
using (PdfStreamWriter fileWriter = new PdfStreamWriter(File.OpenWrite(outputPageFilePath)))
48+
{
49+
fileWriter.WritePage(page);
50+
}
51+
}
52+
PdfFormatProvider provider = new PdfFormatProvider();
53+
RadFixedDocument croppedDocument = provider.Import(File.ReadAllBytes(outputPageFilePath));
54+
Rect middleRectangle = new Rect(0, croppedDocument.Pages.First().Size.Height / 3, croppedDocument.Pages.First().Size.Width, croppedDocument.Pages.First().Size.Height / 3);
55+
foreach (RadFixedPage page in croppedDocument.Pages)
56+
{
57+
page.CropBox = middleRectangle;
58+
}
59+
File.WriteAllBytes(outputPageFilePath, provider.Export(croppedDocument));
60+
Process.Start(new ProcessStartInfo() { FileName = outputPageFilePath, UseShellExecute = true });
61+
}
62+
```
63+
64+
This code snippet demonstrates how to create a new PDF by cropping the center third of a specific page from an existing PDF document. The observed result is illustrated below:
65+
66+
![New PDF document with Cropped Content](images/pdf-with-cropped-page.png)
67+
68+
## See Also
69+
70+
- [RadPdfProcessing Documentation]({%slug radpdfprocessing-overview%})
71+
- [PdfStreamWriter]({%slug radpdfprocessing-formats-and-conversion-pdf-pdfstreamwriter-overview%})
72+
- [Telerik Document Processing SDK Repository](https://github.com/telerik/document-processing-sdk)
73+
- [Cropping PDF Pages and Saving as Images Using RadPdfProcessing]({%slug crop-save-pdf-pages-as-images-radpdfprocessing%})
74+
---

0 commit comments

Comments
 (0)