How to apply css style when using ng-print inAngular JS

Tags: html,css,angularjs

Problem :

I have created PHP page using angular JS. Now, I want to print that page as well as. I have added ngPrint in my app.js and also assign id to the main div. on page preview data are showing perfectly but without css property. I also added ngPrint.css and ngPrint.js .

my code in header section :-

<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/angular.min.js"></script>   
<script src="app/app.js"></script>
<!-- ng-print -->
<link rel="stylesheet" type="text/css" href="css/ngPrint.css">
<script src="js/ngPrint.js"></script>
<!--/ ng-print -->  

on app.js :-

var mainApp = angular.module("IncomeBenefit", ['ngPrint']);

on display page:-

    <div class="main" id="printSectionId" ng-app="IncomeBenefit">
    <h1 class="main_h1_calc">Calculator</h1>    
        <div class="col-main-w-12" ng-controller="displayController">
            <div class="col-main-w-5">
                <div class="form-header-main" ng-repeat="X in names">

                                    <!-- form section -->                           
                                    <div class="form-header">
                                        <div class="form-header-l">Client Age</div>     
                                        <div class="form-header-r">{{X.client_age}}</div>       
                                    <!--/ form section -->      
<button class="btn btn-primary" ng-print print-element-id="printSectionId"><i class="fa fa-print"></i> Print</button>

I don't have any idea. How to add css property to my printable data. I have also tried inline css but can't succeeded . What can I do ?

Solution :

In your style.cssfile try adding the following and see what happends:

@media print {
  body { border: 15px solid black; }

You have to use @media print to apply print styles and include evertyhing inside it but please remember that css support is somewhat limited when printing.

A good tutorial to get started with

    CSS Howto..

    How to make CSS menu bar activated only after my mouse cursor is at the menu.

    how to change :nth element background size

    How to vertical-align:bottom 2 floated divs with text

    How to resize an image in pure HTML/CSS while keeping its proportions?

    How to adjust items in an ordered list without affecting sub-lists?

    How to margin div inside other div?

    How to create grid position elements like in this image css

    How to use jQuery to fade in/out li a:hover css background-color?

    How to define a set of CSS class names so Vim knows how to autocomplete

    how to : change css class of a button in a parent window with javascript or jquery?

    How to fit css textbox to content?

    How to apply CSS to half of a point feature?

    How do you make linked text act as if it is normal text?

    CSS: Checkbox with Border. How to get Space between Border and Content?

    How to add physics to CSS animations?

    CSS: How to get a positioned div to resize horizontally with window instead of getting scrollbars

    How can I show part of an element, and toggle to all of the element on click?

    How to make element fade in on page scroll?

    How to capitalize first line with css? ::first-line psuedo-element CSS not working

    How to Add Another Instance of Date picker in given Code

    multiselect.js via gem multi-select-rails - how best to set width

    How to make AngularJS Materials drop down menues more visable?

    CSS- how to prevent the original title info to be displayed

    How to change CSS of last tab in Bootstrap Tab

    How to apply dynamic CSS for the label in IE7

    How to nest classes in css modules and react?

    How do you disable horizontal scrolling on a webpage?

    CSS 3D containers like shown in post

    How do I get rid of the last tr td bottom border using css?

    How do I link an external css to overwrite bootstrap css for centering elements?