html to pdf doesnt display

6 posts, 0 answers
  1. Menaga
    Menaga avatar
    4 posts
    Member since:
    May 2011

    Posted 27 Jul 2011 Link to this post

    hi

        I have a  table in radeditor.in which values should be  changed at runtime.I have a button on whose click event table should be converted into pdf.I tried this


    <telerik:RadEditor ID="pdffile_dl" runat="server" style="display: none" MaxHtmlLength="20000"    
                ContentFilters="PdfExportFilter, DefaultFilters" >
            <ExportSettings OpenInNewWindow="true" >
            </ExportSettings>        
        
      </telerik:RadEditor>
           
    codebehind:

    string aa="hello";

     protected void  btn_Click(object sender, ImageClickEventArgs e)
        {       
             pdffile_dl.Content="<table><tr><td>"+aa+"</td></tr></table>";

          pdffile_dl.ExportToPdf();
           
        }

    the converted pdf file display nothing

  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 28 Jul 2011 Link to this post

    Hi Menaga,

    The problem occurs because of the <table> element that is added to the content. RadEditor is using third party tool to provide the HTML to PDF conversion and this tool requires table elements to have set width and to have <colgroup>. This is handled by the ExportToPdf filter along with other requirements of that tool, however, since you are dynamically setting the content server-side, content filters are not executed.

    In order to dynamically wrap the content in table when exporting you need to modify the table declaration to match the following:
    protected void btn_Click(object sender, ImageClickEventArgs e)
    {
        pdffile_dl.Content = "<table style=\"width:0px\"><colgroup><col /></colgroup><tr><td>" + aa + "</td></tr></table>";
     
        pdffile_dl.ExportToPdf();
    }
    Please note that you need <col /> element for each column of the table.

    Regards,
    Dobromir
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. Menaga
    Menaga avatar
    4 posts
    Member since:
    May 2011

    Posted 29 Jul 2011 Link to this post

    hi
          thanks for your reply.nw i got a another issue with this.Its work fine with chrome and firefox.but while i using IE ,when i click a button first time it  download the whole aspx page and also doesnt convert to pdf. Pdf conversion correctly occur at  only when i click a button second time..please help me with this.thanks in advance
  4. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 03 Aug 2011 Link to this post

    Hi Menaga,

    I tried to reproduce the problem but to no avail. Could you please provide more detailed information regarding specific scenario?

    • Which version of RadControls for ASP.NET AJAX and .NET Framework are used in the application?
    • Under which browser and its version the problem occurs?
    • Could you please provide a simple fully runnable project reproducing the problem so we can investigate it further?

    All the best,
    Dobromir
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  5. Menaga
    Menaga avatar
    4 posts
    Member since:
    May 2011

    Posted 04 Aug 2011 Link to this post

    Hi 
    Im using  RadControls for ASP.NET AJAX with version Q2011 and .NET3.5 .The problem  occurs in Internet Explorer 8
    table.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="table.aspx.cs" Inherits="table" %>
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <telerik:radscriptmanager runat="server"></telerik:radscriptmanager>
        <asp:Button ID="btn" runat="server" Text="click me to download pdf" onclick="btn_Click" />
        <literal id="literal1" runat="server"></literal>
             
        </div>
        <telerik:radeditor id="radeditor1" runat="server"  ContentFilters="PdfExportFilter, DefaultFilters"><ExportSettings OpenInNewWindow="true" ></ExportSettings>
            <content>
            
            </content>
            </telerik:radeditor>
     
        </form>
    </body>
    </html>

    table.aspx.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
     
    using System.Web.UI.Adapters;
    public partial class table : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string dynTable = "";
                dynTable = "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\">";
                for (int tRows = 0; tRows < 5; tRows++)
                {
                    dynTable += "<tr>";
     
     
                    for (int tCols = 0; tCols < 4; tCols++)
                    {
     
     
                        dynTable += "<td>"; dynTable += "Row: " + (tRows + 1) + " Col: " + (tCols + 1);
     
                        dynTable += "</td>";
                    }
                    dynTable += "</tr>";
     
                }
     
     
     
                // close the table tag
     
                dynTable += "</table>";
     
                 
                radeditor1.Content = dynTable;
            }
        }
        protected void btn_Click(object sender, EventArgs e)
        {
            radeditor1.ExportToPdf();
        }
    }

    thanks in advance
  6. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 08 Aug 2011 Link to this post

    Hi Menaga,

    The generated table is not with the correct formatting. To be able to export <table> to PDF it should to meet the following requirements:
    • A width should be set to the table as a style rule, e.g.:
      <table style="width:0px">
    • The table should contain a column declaration - <colgroup> inner tag, e.g.:
      <table style="width:0px">
          <colgroup>
              <col />
              <col />
              <col />
              <col />
          </colgroup>
      ......


    Greetings,
    Dobromir
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top