
Hello,
Could you please provide me an example or redirect me to a demo where pdf is created from stratch and/or pdf exported from the html input. We currently convert data populated WebForm pages into PDF files all on the server that are never delivered to a user via browser interaction, or even requested by a browser (automated generation.). Aside from an HTML source being easier to use and maintain, it would plug right into our existing situation and not require use to reconstruct our forms in C#.
Thanks.
3 Answers, 1 is accepted
To generate a PDF document from scratch, I would suggest you check our PdfProcessing library. We have several examples on how you could use its API to achieve different requirements in the SDK repository on GitHub.
When you need to convert documents from different formats to PDF, WordsProcessing comes in handy. This library supports converting HTML, DOCX, RTF and plain text documents to PDF. There are samples demonstrating its usage as well: WordsProcessing examples on GitHub.
Hope this helps.
Regards,
Tanya
Progress Telerik

Hi Tanya,
Can you point to any example where a simple table is written to a pdf. We want the table to autofit in to pdf with all the data in the table visible. I refered Table but could not find a complete example. Any help will be highly appreciated., Thanks!
The easiest way to insert such a table would be through RadFixedDocumentEditor. Simple examples in code are available in Examples 7-10 form the Table topic and here is a complete one for creating a table, filling it with data and inserting it into a document:
this
.pdfDocument =
new
RadFixedDocument();
RadFixedDocumentEditor editor =
new
RadFixedDocumentEditor(
this
.pdfDocument);
Table table =
new
Table();
table.LayoutType = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.TableLayoutType.FixedWidth;
table.DefaultCellProperties.Padding =
new
Thickness(5);
Border blackBorder =
new
Border(1,
new
RgbColor(0, 0, 0));
for
(
int
rowIndex = 0; rowIndex < 150; rowIndex++)
{
TableRow row = table.Rows.AddTableRow();
for
(
int
columnIndex = 0; columnIndex < 3; columnIndex++)
{
TableCell cell = row.Cells.AddTableCell();
cell.Borders =
new
TableCellBorders(blackBorder, blackBorder, blackBorder, blackBorder);
cell.Blocks.AddBlock().InsertText(
string
.Format(
"Some sample content in cell[{0}, {1}]"
, rowIndex, columnIndex));
}
}
editor.InsertTable(table);
Hope this will help you achieve the goal.
Regards,
Tanya
Progress Telerik
Hi Suresh,
You can use the Insert Documents functionality of WordsProcessing to import the desired content and insert it inside the table. Here is a sample code of how that can be achieved:
string sampleRTF = @"{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Calibri;}}\viewkind4\uc1\pard\cf1\lang1030\b\f0\fs24 sample RTF content}";
string sampleHTML = "<p><b>sample HTML content</b></p>";
RtfFormatProvider rtfFormatProvider = new RtfFormatProvider();
HtmlFormatProvider htmlFormatProvider = new HtmlFormatProvider();
RadFlowDocument document = new RadFlowDocument();
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
// Insert a table
Table table = editor.InsertTable(5, 2);
// Get the 3rd row of the table
TableRow rowToInsertIn = table.Rows[2];
// Insert HTML in the first column of the third row
Paragraph paragraphInFirstCell = rowToInsertIn.Cells[0].Blocks.AddParagraph();
editor.MoveToParagraphStart(paragraphInFirstCell);
editor.InsertDocument(htmlFormatProvider.Import(sampleHTML));
// Insert RTF in the second column of the third row
Paragraph paragraphInSecondCell = rowToInsertIn.Cells[1].Blocks.AddParagraph();
editor.MoveToParagraphStart(paragraphInSecondCell);
editor.InsertDocument(rtfFormatProvider.Import(sampleRTF));
Hope this is helpful.