How to print div and maintain skin adn borders etc.

3 posts, 0 answers
  1. Al
    Al avatar
    203 posts
    Member since:
    Oct 2006

    Posted 01 Sep Link to this post

    Hi,

    I am using the code below in an attempt to print out a portion of a page contained in a div. The div contains a RadPageLayout and some other rad controls but when I print the style of the controls is lost (radpagelayout loses it table form and all fonts default to standard) - obviously the style being applied by skin is not included in the window being opened - is it possible to print like this and keep the skin, font etc?

     

    function PrintElement(id, width, height) {
        var prtContent = document.getElementById(id);
        var WinPrint = window.open('', '', 'left=0,top=0,width='+width+',height='+height+',toolbar=0,scrollbars=0,status=0,dir=ltr');
        WinPrint.document.write(prtContent.innerHTML);
        WinPrint.document.close();
        WinPrint.focus();
        WinPrint.print();
        WinPrint.close(); 
    }

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 01 Sep Link to this post

    Hello Al,

    With this approach you would also need to bring over the <link> elements for the stylesheets which takes some code.

    An alternative I can suggest is that you look into using @media queries to hide the irrelevant content with CSS instead of writing to a new document. You can see similar approach used in this demo.

    Regards,

    Marin Bratanov
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Al
    Al avatar
    203 posts
    Member since:
    Oct 2006

    Posted 01 Sep in reply to Marin Bratanov Link to this post

    Thanks Marin, the @media query seems to do the job.
Back to Top