This is a migrated thread and some comments may be shown as answers.

How to print div and maintain skin adn borders etc.

2 Answers 252 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Al
Top achievements
Rank 1
Iron
Iron
Iron
Al asked on 01 Sep 2016, 08:38 AM

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 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 01 Sep 2016, 08:49 AM

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.
0
Al
Top achievements
Rank 1
Iron
Iron
Iron
answered on 01 Sep 2016, 09:43 AM
Thanks Marin, the @media query seems to do the job.
Tags
General Discussions
Asked by
Al
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Marin Bratanov
Telerik team
Al
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or