2

I put the html for print in a div with class forPrint which is in a material dialog page and call the window.print() when the print button is clicked in the angular component.
However, it shows/prints only the page in the current screen and the rest is cut off when the button is clicked.
How to print the whole content in the div with class forPrint?
I think the reason is material dialog because when I print something in a normal page it works fine.

CSS:

@media print {
    /deep/ body * { visibility: hidden; }
    /deep/ .forPrint * { visibility: visible; display:block;}
    /deep/ .forPrint { display:block;position: absolute; top: 40px; left: 30px; } 

}
2
  • it may have something to do with position: absolute; and only supplying top/left ... add bottom:40px; right:30px; (I'm assuming you've done the above to add margins to the printed document) Commented Nov 10, 2017 at 3:36
  • I think the reason is the material dialog, because when I print something in a normal page it works fine Commented Nov 10, 2017 at 7:32

2 Answers 2

1

To print whole content of class-forPrint or page use below CSS

@media print {
      body, html, .forPrint{
          width: 100%;
          height:100%;
      }
}
Sign up to request clarification or add additional context in comments.

Comments

1

I had such a problem when used material sidenav. Try create forPrint div beyond sidenav container.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.