-
Notifications
You must be signed in to change notification settings - Fork 41
Added new kb article generate-table-with-radfixeddocumenteditor #494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
YoanKar
merged 3 commits into
master
from
new-kb-generate-table-with-radfixeddocumenteditor-240df202cb474031a3a099aa388e388e
Feb 25, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
knowledge-base/generate-table-with-radfixeddocumenteditor.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| --- | ||
| title: Generating a Table with RadFixedDocumentEditor | ||
| description: Learn how to build a table using the RadFixedDocumentEditor for flow-like content management in RadPdfProcessing. | ||
| type: how-to | ||
| page_title: How to Generate a Table with RadFixedDocumentEditor | ||
| slug: generate-table-with-radfixeddocumenteditor | ||
| tags: pdf, document, processing, fixedcontenteditor, fixeddocumenteditor, edit, table,flow, position | ||
| res_type: kb | ||
| ticketid: 1674934 | ||
| --- | ||
| | Version | Product | Author | | ||
| | ---- | ---- | ---- | | ||
| | 2024.4.1106| RadPdfProcessing |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)| | ||
|
|
||
| ## Description | ||
|
|
||
| When creating or editing a PDF document using [RadPdfProcessing]({%slug radpdfprocessing-overview%}), understanding how to manage the positioning of elements is essential. To eliminate the necessity of repositioning all elements below a newly added element in the middle of the PDF file, explore the functionality offerred by the [RadFixedDocumentEditor]({%slug radpdfprocessing-editing-radfixeddocumenteditor%}) to generate a PDF table. | ||
|
|
||
| ## Solution | ||
|
|
||
| RadPdfProcessing offers the [RadFixedDocumentEditor]({%slug radpdfprocessing-editing-radfixeddocumenteditor%}, which allows for a flow-like content management approach and allows you to insert all desired elements one after another without calculating the elements' position. We will use this approach for generating the PDF table. | ||
|
|
||
| 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. | ||
|
|
||
| The following example demonstrates how to create a table which result is illustrated below: | ||
|
|
||
| ```csharp | ||
| RadFixedDocument radFixedDocument = new RadFixedDocument(); | ||
| RadFixedDocumentEditor radFixedDocumentEditor = new RadFixedDocumentEditor(radFixedDocument); | ||
|
|
||
| Table table = new Table(); | ||
| table.LayoutType = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.TableLayoutType.FixedWidth; | ||
|
|
||
| TableRow row = table.Rows.AddTableRow(); | ||
| TableCell cell = row.Cells.AddTableCell(); | ||
| cell.Blocks.AddBlock().InsertText("Account No."); | ||
| cell.Blocks.AddBlock().InsertText("12345678910"); | ||
|
|
||
| cell = row.Cells.AddTableCell(); | ||
| cell.Background = new RgbColor(255, 100, 100); | ||
| cell.Blocks.AddBlock().InsertText("Statement Date"); | ||
| cell.Blocks.AddBlock().InsertText("November 15, 2021"); | ||
|
|
||
| row = table.Rows.AddTableRow(); | ||
| cell = row.Cells.AddTableCell(); | ||
| cell.Blocks.AddBlock().InsertText(" "); | ||
| cell = row.Cells.AddTableCell(); | ||
| cell.Background = new RgbColor(255, 100, 100); | ||
|
|
||
| row = table.Rows.AddTableRow(); | ||
| cell = row.Cells.AddTableCell(); | ||
| cell.Blocks.AddBlock().InsertText("Account Name"); | ||
| cell.Blocks.AddBlock().InsertText("Leslie Holden"); | ||
|
|
||
| cell = row.Cells.AddTableCell(); | ||
| cell.Background = new RgbColor(255, 100, 100); | ||
| cell.Blocks.AddBlock().InsertText("Period Statement from"); | ||
| cell.Blocks.AddBlock().InsertText("November 1, 2021");; | ||
|
|
||
dessyordanova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| row = table.Rows.AddTableRow(); | ||
| cell = row.Cells.AddTableCell(); | ||
| cell.Blocks.AddBlock().InsertText(" "); | ||
| cell = row.Cells.AddTableCell(); | ||
| cell.Background = new RgbColor(255, 100, 100); | ||
|
|
||
| row = table.Rows.AddTableRow(); | ||
| cell = row.Cells.AddTableCell(); | ||
| cell.Blocks.AddBlock().InsertText("Address"); | ||
| cell.Blocks.AddBlock().InsertText("4344 Poco Mas Drive"); | ||
| cell.Blocks.AddBlock().InsertText("Dallas, FL, 33009"); | ||
|
|
||
| cell = row.Cells.AddTableCell(); | ||
| cell.Background = new RgbColor(255, 100, 100); | ||
| cell.Blocks.AddBlock().InsertText("Period Statement until"); | ||
| cell.Blocks.AddBlock().InsertText("November 13, 2021"); | ||
|
|
||
| radFixedDocumentEditor.InsertTable(table); | ||
|
|
||
| radFixedDocumentEditor.Dispose(); | ||
|
|
||
dessyordanova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| string outputFilePath = "output.pdf"; | ||
| File.Delete(outputFilePath); | ||
| PdfFormatProvider provider = new PdfFormatProvider(); | ||
| using (Stream output = File.OpenWrite(outputFilePath)) | ||
| { | ||
| provider.Export(radFixedDocument, output, TimeSpan.FromSeconds(10)); | ||
| } | ||
|
|
||
| Process.Start(new ProcessStartInfo() { FileName = outputFilePath, UseShellExecute = true }); | ||
| ``` | ||
|
|
||
| The observed result is illustrated below: | ||
|
|
||
|  | ||
|
|
||
| >note RadPdfProcessing offers an alternative approach with **[FixedContentEditor]({%slug radpdfprocessing-editing-fixedcontenteditor%})**. However, it requires managing the Position at which the document elements will be drawn. 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. | ||
|
|
||
| ## See Also | ||
| - [RadPdfProcessing]({%slug radpdfprocessing-overview%}) | ||
| - [RadFixedDocumentEditor]({%slug radpdfprocessing-editing-radfixeddocumenteditor%}) | ||
| - [Table]({%slug radpdfprocessing-editing-table%}) | ||
| - [Creating Custom Layout Tables with RadPdfProcessing]({%slug customize-table-layout-radpdfprocessing%}) | ||
| - [How to Generate a Table with Images with PdfProcessing]({%slug generate-table-with-images-pdf-processing%}) | ||
|
|
||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.