jquery - Bootstrap style no applying to print -


i have following code print table held application:

    var elementtoprint = this.maintable.get(0);      newwin = window.open("");     newwin.document.write('<html><head><title>' + elementtoprint.caption + '</title>' +                         '</head><body class=\'visible-print\'>');     newwin.document.write(elementtoprint.outerhtml);     newwin.print();     newwin.close(); 

where this.maintable jquery object.

at common page (_layout.cshtml) have:

<head>     <meta http-equiv="content-type" content="text/html; charset=utf-8" />     <meta charset="utf-8" />      <title>myapp</title>      <meta name="viewport" content="width=device-width, initial-scale=1.0">      <link href="@url.content("~/content/bootstrap.css")" rel="stylesheet" media="all">     <link href="@url.content("~/content/bootstrap-theme.min.css")" rel="stylesheet" media="all"> </head> 

the print routine runs fine, except looses styling, printing plain text unformatted data (side side data).

i need keep original bootstrap layout (colors, borders, strips, etc.). please needs changed...

thanks,

when create new window, creates new html page does not inherit master page. new html page not have bootstrap css references.

you should adding these bootstrap css references while document.write follows,

newwin.document.write('<html><head><title>' + elementtoprint.caption + '</title>'); newwin.document.write('<link href="your-path/bootstrap.min.css" rel="stylesheet" />'); newwin.document.write('<link href="your-path/bootstrap-theme.min.css" rel="stylesheet" />'); newwin.document.write('</head><body class=\'visible-print\'>'); 

update standard twitter-bootstrap contain css rules media type print follows, removes screen css rules,

@media print {   * {     color: #000 !important;     text-shadow: none !important;     background: transparent !important;     box-shadow: none !important;   } 

you need custom bootstrap, out "print media styles" (recomended) or manually remove these @media print.

here plunker shows printing bootstrap css styles


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -