Skip to content

Commit 8651ad9

Browse files
committed
new KB - Generating a Table with RadFixedDocumentEditor
1 parent b3be51e commit 8651ad9

File tree

4 files changed

+92
-14
lines changed

4 files changed

+92
-14
lines changed

knowledge-base/generate-table-with-radfixeddocumenteditor.md

Lines changed: 90 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how to build a table using RadFixedDocumentEditor in RadPdfPr
44
type: how-to
55
page_title: How to Generate a Table with RadFixedDocumentEditor
66
slug: generate-table-with-radfixeddocumenteditor
7-
tags: radpdfprocessing, document processing, fixedcontenteditor, radfixeddocumenteditor, pdf, editing
7+
tags: pdf, document, processing, fixedcontenteditor, radfixeddocumenteditor, edit, table
88
res_type: kb
99
ticketid: 1674934
1010
---
@@ -13,28 +13,104 @@ ticketid: 1674934
1313
| 2024.4.1106| RadPdfProcessing |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)|
1414

1515
## Description
16-
When creating or editing a PDF document using RadPdfProcessing, understanding how to manage the positioning of elements is essential. This knowledge base article addresses the question of whether it's necessary to reposition all elements below a newly added element in the middle of the PDF file using [FixedContentEditor](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/editing/fixedcontenteditor) and explores the existence of a design tool for creating PDF documents. This knowledge base article also answers the following questions:
17-
- How to generate a PDF document from images using FixedContentEditor?
18-
- How to add a watermark to PDF files using RadPdfProcessing?
19-
- Is there a design tool provided by Telerik for creating PDF documents?
16+
17+
When creating or editing a PDF document using [RadPdfProcessing]({%slug radpdfprocessing-overview%}), understanding how to manage the positioning of elements is essential. This knowledge base article addresses the question of whether it's necessary to reposition all elements below a newly added element in the middle of the PDF file using [FixedContentEditor]({%slug radpdfprocessing-editing-fixedcontenteditor%}) and explores the alternative functionality offerred by the [RadFixedDocumentEditor]({%slug radpdfprocessing-editing-radfixeddocumenteditor%}) to generate a PDF table.
2018

2119
## Solution
20+
21+
RadPdfProcessing offers two options for manipulating the content in a PDF document:
22+
23+
* **[FixedContentEditor]({%slug radpdfprocessing-editing-fixedcontenteditor%})** - requires managing the Position at which the document elements will be drawn.
24+
25+
* **[RadFixedDocumentEditor]({%slug radpdfprocessing-editing-radfixeddocumenteditor%})** - manages the document's content in a flow-like manner and allows you to insert all desired elements one after another without calculating the elements' position.
26+
2227
### Managing Elements with FixedContentEditor
23-
The [FixedContentEditor](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/editing/fixedcontenteditor) in RadPdfProcessing enables precise control over the element's positioning within a PDF page. It acts as a pencil, allowing content to be drawn at specific locations. After adding an element, adjust the editor's Position to prevent overlapping with subsequent elements. This method requires manual management of each element's position, especially when inserting a new element amidst existing ones.
28+
29+
The [FixedContentEditor]({%slug radpdfprocessing-editing-fixedcontenteditor%}) in RadPdfProcessing enables precise control over the element's positioning within a PDF page. It acts as a pencil, allowing content to be drawn at specific locations. After adding an element, adjust the editor's Position to prevent overlapping with subsequent elements. This method requires manual management of each element's position, especially when inserting a new element amidst existing ones.
2430

2531
For more insights on using FixedContentEditor effectively, consider reviewing these resources:
26-
- [How to Generate a PDF Document from Images with FixedContentEditor](https://docs.telerik.com/devtools/document-processing/knowledge-base/pdf-from-images-with-fixedcontenteditor)
27-
- [Adding a Watermark to PDF Files Using RadPdfProcessing](https://docs.telerik.com/devtools/document-processing/knowledge-base/add-watermark-pdf-radpdfprocessing)
32+
- [Creating Custom Layout Tables with RadPdfProcessing]({%slug customize-table-layout-radpdfprocessing%})
33+
- [How to Generate a Table with Images with PdfProcessing]({%slug generate-table-with-images-pdf-processing%})
2834

2935
### Flow-Like Content Management with RadFixedDocumentEditor
30-
Alternatively, RadPdfProcessing offers the [RadFixedDocumentEditor](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/editing/radfixeddocumenteditor), which allows for a flow-like content management approach. This editor automates the positioning of elements, enabling you to insert content sequentially without manually calculating positions. This option might be more suitable for scenarios where manual positioning is cumbersome.
3136

32-
### Design Tool for Creating PDF
33-
Regarding the query on a design tool for PDF creation, Telerik Document Processing is primarily focused on processing document formats programmatically and does not include a design tool for PDF creation. The functionality to visually design and edit PDF documents typically falls within UI components like a PDF viewer, which is outside the scope of the Telerik Document Processing libraries.
37+
Alternatively, RadPdfProcessing offers the [RadFixedDocumentEditor]({%slug radpdfprocessing-editing-radfixeddocumenteditor%}, which allows for a flow-like content management approach. This editor automates the positioning of elements, enabling you to insert content sequentially without manually calculating positions. This option might be more suitable for scenarios where manual positioning is cumbersome.
38+
39+
The following example demonstrates how to create a table which result is illustrated below:
40+
41+
```csharp
42+
RadFixedDocument radFixedDocument = new RadFixedDocument();
43+
RadFixedDocumentEditor radFixedDocumentEditor = new RadFixedDocumentEditor(radFixedDocument);
44+
45+
Table table = new Table();
46+
table.LayoutType = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.TableLayoutType.FixedWidth;
47+
48+
TableRow row = table.Rows.AddTableRow();
49+
TableCell cell = row.Cells.AddTableCell();
50+
cell.Blocks.AddBlock().InsertText("Account No.");
51+
cell.Blocks.AddBlock().InsertText("12345678910");
52+
53+
cell = row.Cells.AddTableCell();
54+
cell.Background = new RgbColor(255, 100, 100);
55+
cell.Blocks.AddBlock().InsertText("Statement Date");
56+
cell.Blocks.AddBlock().InsertText("November 15, 2021");
57+
58+
59+
row = table.Rows.AddTableRow();
60+
cell = row.Cells.AddTableCell();
61+
cell.Blocks.AddBlock().InsertText(" ");
62+
cell = row.Cells.AddTableCell();
63+
cell.Background = new RgbColor(255, 100, 100);
64+
65+
row = table.Rows.AddTableRow();
66+
cell = row.Cells.AddTableCell();
67+
cell.Blocks.AddBlock().InsertText("Account Name");
68+
cell.Blocks.AddBlock().InsertText("Leslie Holden");
69+
70+
cell = row.Cells.AddTableCell();
71+
cell.Background = new RgbColor(255, 100, 100);
72+
cell.Blocks.AddBlock().InsertText("Period Statement from");
73+
cell.Blocks.AddBlock().InsertText("November 1, 2021");;
74+
75+
76+
row = table.Rows.AddTableRow();
77+
cell = row.Cells.AddTableCell();
78+
cell.Blocks.AddBlock().InsertText(" ");
79+
cell = row.Cells.AddTableCell();
80+
cell.Background = new RgbColor(255, 100, 100);
81+
82+
row = table.Rows.AddTableRow();
83+
cell = row.Cells.AddTableCell();
84+
cell.Blocks.AddBlock().InsertText("Address");
85+
cell.Blocks.AddBlock().InsertText("4344 Poco Mas Drive");
86+
cell.Blocks.AddBlock().InsertText("Dallas, FL, 33009");
87+
88+
cell = row.Cells.AddTableCell();
89+
cell.Background = new RgbColor(255, 100, 100);
90+
cell.Blocks.AddBlock().InsertText("Period Statement until");
91+
cell.Blocks.AddBlock().InsertText("November 13, 2021");
92+
93+
radFixedDocumentEditor.InsertTable(table);
94+
95+
radFixedDocumentEditor.Dispose();
96+
97+
98+
string outputFilePath = "output.pdf";
99+
File.Delete(outputFilePath);
100+
PdfFormatProvider provider = new PdfFormatProvider();
101+
using (Stream output = File.OpenWrite(outputFilePath))
102+
{
103+
provider.Export(radFixedDocument, output, TimeSpan.FromSeconds(10));
104+
}
105+
106+
Process.Start(new ProcessStartInfo() { FileName = outputFilePath, UseShellExecute = true });
107+
```
108+
109+
![Table with RadFixedDocumentEditor](images/pdf-table-with-radfixeddocumenteditor.png)
34110

35111
## See Also
36-
- [RadPdfProcessing Overview](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/overview)
37-
- [RadFixedDocumentEditor Documentation](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/editing/radfixeddocumenteditor)
38-
- [Introduction to Telerik Document Processing](https://docs.telerik.com/devtools/document-processing/introduction)
112+
- [RadPdfProcessing]({%slug radpdfprocessing-overview%})
113+
- [RadFixedDocumentEditor]({%slug radpdfprocessing-editing-radfixeddocumenteditor%})
114+
- [Table]({%slug radpdfprocessing-editing-table%})
39115

40116

15.5 KB
Loading

libraries/radpdfprocessing/editing/radfixeddocumenteditor.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,4 @@ There is an additional overload of InsertFormInline() that enables you to pass t
323323
* [ImageSource]({%slug radpdfprocessing-model-imagesource%})
324324
* [Table]({%slug radpdfprocessing-editing-table%})
325325
* [How to Generate a PDF Document from Images with RadFixedDocumentEditor]({%slug pdf-from-images-with-radfixeddocumenteditor%})
326+
* [Generating a Table with RadFixedDocumentEditor]({%slug generate-table-with-radfixeddocumenteditor%})

libraries/radpdfprocessing/editing/table.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,4 +298,5 @@ As of **Q3 2024**, along with the BorderStyle.*Single*, RadPdfProcessing offers
298298
* [How to Generate a Table with Images with PdfProcessing]({%slug generate-table-with-images-pdf-processing%})
299299
* [Creating Custom Layout Tables with RadPdfProcessing]({%slug customize-table-layout-radpdfprocessing%})
300300
* [Implementing Column Span in RadPdfProcessing Tables]({%slug table-column-span-radpdfprocessing%})
301+
* [Generating a Table with RadFixedDocumentEditor]({%slug generate-table-with-radfixeddocumenteditor%})
301302

0 commit comments

Comments
 (0)