Reputation: 1507
The problem is that the user has to scroll down to view all of the content within the modal body. However, when I print the modal the only part that is printed is the part that is viewable. I want the entire modal's content to be printed. I have tried every piece of code on the following page and none of them print the entire modal.
Twitter Bootstrap: Print content of modal window
Upvotes: 21
Views: 42651
Reputation: 3966
http://plnkr.co/edit/fspygnqWhsosqDTds0Og?p=preview
/**Modal Styles for Print**/
@media print {
body * {
visibility: hidden;
}
#print-content * {
visibility: visible;
overflow: visible;
}
#mainPage * {
display: none;
}
.modal {
margin: 0;
padding: 0;
min-height: 550px;
visibility: visible;
/**Remove scrollbar for printing.**/
overflow: visible !important;
position: relative;
}
.modal-dialog {
visibility: visible !important;
/**Remove scrollbar for printing.**/
overflow: visible !important;
}
Upvotes: 1
Reputation: 213
@Abu Sulaiman: Using this still prints out only the part showing in the modal. To also show the hidden part especially when your content is overflow, change the removeInline: true
just as done below. Works fine for me.
Download printThis.js from the following link and include it in your html: https://github.com/jasonday/printThis/blob/0a7f799693af8a8303bf0b8df0efc80c2694af81/printThis.js
Wrap the content you want to print with the following div. Everything outside of this div will not be printed.
..content to print..Call the following jquery to print all the content including the content that is not viewable. You may include your css files in an array if you have multiple css files.
$("#modalDiv").printThis({
debug: false,
importCSS: true,
importStyle: true,
printContainer: true,
loadCSS: "../css/style.css",
pageTitle: "My Modal",
removeInline: true,
printDelay: 333,
header: null,
formValues: true
});
Upvotes: 0
Reputation: 10194
Was facing the same issue with angularjs UI bootstrap library. Tried the link provided above but no luck. The only CSS that works for me when the modal is LONGER than the view port is:
@media print {
.modal {
position: absolute;
left: 0;
top: 0;
margin: 0;
padding: 0;
overflow: visible!important;
}
}
Note: position:absolute
and overflow:visible
are MUST have.
Hope this could also solve your problem when printing angularUI-Bootstrap-Modal.
Upvotes: 24
Reputation: 1390
I think you can easily do that with CSS using @media print
:
If there is opened bootstrap modal window, will be printed content of modal (it can be more than one page), in other case content of window.
@media print {
/* on modal open bootstrap adds class "modal-open" to body, so you can handle that case and hide body */
body.modal-open {
visibility: hidden;
}
body.modal-open .modal .modal-header,
body.modal-open .modal .modal-body {
visibility: visible; /* make visible modal body and header */
}
}
Also you can add button on footer of modal for printing:
<div class="modal-footer">
<button type="button" class="btn btn-default" onclick="js:window.print()">print modal content</button>
</div>
Upvotes: 10
Reputation: 1507
Download printThis.js from the following link and include it in your html: https://github.com/jasonday/printThis/blob/0a7f799693af8a8303bf0b8df0efc80c2694af81/printThis.js
Wrap the content you want to print with the following div. Everything outside of this div will not be printed.
<div id="modalDiv">
..content to print..
</div>
Call the following jquery to print all the content including the content that is not viewable. You may include your css files in an array if you have multiple css files.
$("#modalDiv").printThis({
debug: false,
importCSS: true,
importStyle: true,
printContainer: true,
loadCSS: "../css/style.css",
pageTitle: "My Modal",
removeInline: false,
printDelay: 333,
header: null,
formValues: true
});
Upvotes: 14