Home / Community & Support / Knowledge Base / RadControls for ASP.NET AJAX / Editor / Converting RadEditor HTML to PDF format

Converting RadEditor HTML to PDF format

Article Info

Rating: 5

Article information

Article relates to

 RadEditor Classic and RadEditor for ASP.NET AJAX

Created by

 Rumen Jekov

Last modified

 2008/04/01

Last modified by

 Georgi Popivanov



The example below illustrates how you can convert the HTML of RadEditor to PDF format using an HTML2PDF convertor tool of Tall Components. For a live demo, please go to http://www.tallcomponents.com/cp0803.aspx
 
 

ASPX code
<form id="Form1" method="post" runat="server">  
    <rade:RadEditor id="RadEditor1" Runat="server"></rade:RadEditor> 
    <asp:button id="showPDF" runat="server" Text="Show PDF"></asp:button> 
</form> 

                 
C# code
private void showPDF_Click(object sender, EventArgs e)  
{  
    string html = "<html>" + RadEditor1.Html + "</html>";  
    TallComponents.PDF.Layout.Document document = new TallComponents.PDF.Layout.Document();  
    TallComponents.PDF.Layout.Section section = document.Sections.Add();  
 
    TallComponents.PDF.Layout.HtmlParagraph htmlParagraph = new TallComponents.PDF.Layout.HtmlParagraph();  
    htmlParagraph.FontPath = "fonts";  
    htmlParagraph.Text = html;  
    section.Paragraphs.Add( htmlParagraph );  
    Response.Clear();  
    document.Write( Response );  
    Response.End();  
 

VB.NET code
Private Sub showPDF_Click(ByVal sender As ObjectByVal e As EventArgs)  
 Dim html As String = "<html>" + RadEditor1.Html + "</html>" 
 Dim document As TallComponents.PDF.Layout.Document = New TallComponents.PDF.Layout.Document  
 Dim section As TallComponents.PDF.Layout.Section = document.Sections.Add  
 Dim htmlParagraph As TallComponents.PDF.Layout.HtmlParagraph = New TallComponents.PDF.Layout.HtmlParagraph  
 htmlParagraph.FontPath = "fonts" 
 htmlParagraph.Text = html  
 section.Paragraphs.Add(htmlParagraph)  
 Response.Clear  
 document.Write(Response)  
 Response.End 
End Sub 





ASPX code
<form id="Form1" method="post" runat="server">  
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <telerik:RadEditor id="RadEditor1" Runat="server"></telerik:RadEditor> 
    <asp:button id="showPDF" runat="server" Text="Show PDF"></asp:button> 
</form> 

                 
C# code
private void showPDF_Click(object sender, EventArgs e)  
{  
    string html = "<html>" + RadEditor1.Content + "</html>";  
    TallComponents.PDF.Layout.Document document = new TallComponents.PDF.Layout.Document();  
    TallComponents.PDF.Layout.Section section = document.Sections.Add();  
 
    TallComponents.PDF.Layout.HtmlParagraph htmlParagraph = new TallComponents.PDF.Layout.HtmlParagraph();  
    htmlParagraph.FontPath = "fonts";  
    htmlParagraph.Text = html;  
    section.Paragraphs.Add( htmlParagraph );  
    Response.Clear();  
    document.Write( Response );  
    Response.End();  
 

VB.NET code
Private Sub showPDF_Click(ByVal sender As ObjectByVal e As EventArgs)  
 Dim html As String = "<html>" + RadEditor1.Content+ "</html>" 
 Dim document As TallComponents.PDF.Layout.Document = New TallComponents.PDF.Layout.Document  
 Dim section As TallComponents.PDF.Layout.Section = document.Sections.Add  
 Dim htmlParagraph As TallComponents.PDF.Layout.HtmlParagraph = New TallComponents.PDF.Layout.HtmlParagraph  
 htmlParagraph.FontPath = "fonts" 
 htmlParagraph.Text = html  
 section.Paragraphs.Add(htmlParagraph)  
 Response.Clear  
 document.Write(Response)  
 Response.End 
End Sub 


In the "Article Files" section, there is attached a sample project with RadEditor 6.1 demonstrating the described functionality.

Article Links

Comments

If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.