我当时正在使用Bootstrap Grid并进行布局。我要打印与网页上显示的完全相同的布局,并且布局不变。我尝试使用某种使用javascript的打印方法来添加自定义CSS代码,但这些都是徒劳的。
这是我要打印完全相同的示例布局(Fiddle)。
我尝试的最后一个打印JavaScript代码是:
<script>
var all_source_content = document.documentElement.innerHTML;
var DocumentContainer = document.getElementById('main_container');
var WindowObject = window.open('', 'PrintWindow', '');
WindowObject.document.writeln('<!DOCTYPE html>');
WindowObject.document.writeln('<html><head><title></title>');
WindowObject.document.writeln('<link rel="stylesheet" href="https://getbootstrap.com/docs/3.3/dist/css/bootstrap.min.css">');
WindowObject.document.writeln('<style></style>');
WindowObject.document.writeln('</head><body>');
console.log(DocumentContainer.innerHTML);
WindowObject.document.writeln(DocumentContainer.innerHTML);
WindowObject.document.writeln('</body></html>');
WindowObject.document.close();
WindowObject.focus();
WindowObject.print();
</script>
但这也没有帮助我。
我想要的布局:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句