Bootstrap Gridを使用して、レイアウトを作成しました。Webページに表示されているものとまったく同じ、同じレイアウトで印刷したい変更なし。カスタムCSSコードを追加するためにjavascriptを使用したある種の印刷方法を使用しようとしましたが、すべて無駄でした。
これが、まったく同じように印刷したいサンプルレイアウト(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]
コメントを追加