- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在我的应用程序中使用 Angular 2。我有一个名为 test.component.ts 的组件,该组件的 templateurl 是 test.component.html,styleurl 是 test.component.css。我在 test.component.html 页面上有一个打印按钮。我需要使用打印按钮在同一页面 (test.component.html) 上打印名为“打印数据”的 div 的内容。 div 'print-data' 使用 test.component.css 文件中定义的 css 类。我可以在浏览器上看到应用的 css,但是当我单击打印按钮时,打印窗口显示 div 内的文本,但没有应用任何 css。类型脚本代码是:
var mywindow = window.open('', 'PRINT', 'height=800,width=800');
let printdiv = document.getElementById('print-data');
mywindow.document.write(printdiv.innerHTML);
mywindow.focus();
mywindow.print();
当我尝试将链接附加到 test.component.css 时,如下所示:
var mywindow = window.open('', 'PRINT', 'height=800,width=800');
let printdiv = document.getElementById('print-data');
mywindow.document.write(`<html><head><link rel="stylesheet"
type="text/css" href="test.component.css" /></head><body>`);
mywindow.document.write(printdiv.innerHTML);
mywindow.document.write('</body></html>');
mywindow.focus();
mywindow.print();
在打印窗口控制台上,它显示“无法加载资源:服务器响应状态为 404(未找到)test.component.css”。
我无法在打印窗口内容中附加我的 test.component.css 文件类。请帮帮我。
最佳答案
<form id="form1">
<div id="dvContainer">
</di>
</form>
<!-- imprimir hoja -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$("#btnPrint").live("click", function () {
var divContents = $("#dvContainer").html();
var printWindow = window.open('', '', 'height=400,width=800');
printWindow.document.write('<head><title>LISTA DE VERIFICACIÓN</title> \
\ <style> body {font-size: 16px;font-weight: 400;line-height: 24px;letter-spacing: 1px;height: 100%;font-family:"Poppins", sans-serif;color:#333;}.formspace1{margin-bottom: 10px;}.modal-content{box-shadow: 0 5px 15px rgba(0,0,0,.5);position:relative;background-color: #fff;background-clip: padding-box;border: 1px solid rgba(0,0,0,.2);border-radius:6px;outline:0;}#modalColor{background-color: #f0ad4e !important;text-align: center !important;}.modal-header{padding: 15px;border-bottom: 1px solid #e5e5e5;}.modal-title{margin: 0;line-height: 1.42857143;}h1, h2, h3, h4, h5, h6 {font-family: "Poppins", sans-serif;} .h4,h4{font-size: 18px;}.btext{font-size: 24px !important;}b,strong {font-weight: 700;} .margin-x{margin-top: 0px;}modal-body{position: relative;padding: 15px;} *{-webkit-box-sizing:border-box;-moz-box-sizing: border-box;box-sizing: border-box;} .panel-warning{border-color: #faebcc;}.panel {margin-bottom: 20px;background-color: #fff;border: 1px solid transparent;border-radius: 4px;-webkit-box-shadow: 0 1px 1px rgba(0,0,0,.05);box-shadow: 0 1px 1px rgba(0,0,0,.05);}.panel-default {border-color: #ddd;}.panel-warning>.panel-heading{color: #8a6d3b;background-color: #fcf8e3;border-color: #faebcc;padding: 10px 15px;border-bottom: 1px solid transparent;border-top-left-radius: 3px;border-top-right-radius: 3px;}.panel>.table-responsive:last-child>.table:last-child, .panel>.table:last-child{border-bottom-right-radius: 3px;border-bottom-left-radius: 3px;}.panel>.panel-collapse>.table, .panel>.table, .panel>.table-responsive>.table {margin-bottom: 0;}.table {width: 100%;max-width: 100%;margin-bottom: 20px;background-color: transparent; border-spacing: 0;border-collapse: collapse;white-space: normal;line-height: normal;font-weight: normal;font-size: medium;font-style: normal;color: -internal-quirk-inherit;text-align: start; font-variant: normal;display: table;border-color: grey;} thead{display: table-header-group;vertical-align: middle;border-color: inherit;}tr {display:table-row;vertical-align: inherit;border-color: inherit;}.table>caption+thead>tr:first-child>td, .table>caption+thead>tr:first-child>th, .table>colgroup+thead>tr:first-child>td, .table>colgroup+thead>tr:first-child>th, .table>thead:first-child>tr:first-child>td, .table>thead:first-child>tr:first-child>th {border-top: 0;} .table>thead>tr>th{vertical-align:bottom;border-bottom: 2px solid #ddd;}.text-center{text-align: center;}tr {display: table-row;vertical-align: inherit; border-color: inherit;}tbody {display: table-row-group; vertical-align: middle;border-color: inherit;}.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th {padding: 8px;line-height: 1.42857143;vertical-align: top;border-top: 1px solid #ddd;}td[Attributes Style] {width: 168px;}.form-horizontal .checkbox, .form-horizontal .checkbox-inline, .form-horizontal .radio, .form-horizontal .radio-inline {padding-top: 7px; margin-top: 0;margin-bottom: 0;}.checkbox-inline, .radio-inline {position: relative; display: inline-block;padding-left: 20px;margin-bottom: 0;font-weight: 400;vertical-align: middle; cursor: pointer;}label {display: inline-block;max-width: 100%;margin-bottom: 5px;font-weight: 700;}.checkbox input[type=checkbox], .checkbox-inline input[type=checkbox], .radio input[type=radio], .radio-inline input[type=radio] {position: absolute;margin-top: 4px\9;margin-left: -20px;}nput[type=checkbox], input[type=radio] {margin: 4px 0 0;margin-top: 1px\9;line-height: normal;box-sizing: border-box;padding: 0;}button, input, select, textarea {font-family: inherit;font-size: inherit; line-height: inherit;}button, input, optgroup, select, textarea {margin: 0;font: inherit; color: inherit;}.text-justify {text-align: justify;}tbody {display: table-row-group;vertical-align: middle; border-color: inherit;}.form-horizontal .form-group { margin-right: -15px; margin-left: -15px;}.formspace { margin-bottom: 4px;}@media (min-width: 768px).col-sm-offset-6 {margin-left: 50%;}@media (min-width: 768px).col-sm-3 {width: 25%;}.col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9 {position: relative; min-height: 1px;padding-right: 15px;padding-left: 15px;}@media (min-width: 768px).col-sm-offset-6 {margin-left: 50%;}.navbar-btn {margin-top: 8px; margin-bottom: 8px;} .btn-group-lg>.btn, .btn-lg {padding: 10px 16px;font-size: 18px;line-height: 1.3333333; border-radius: 6px;} btn-warning {color: #fff;background-color: #f0ad4e; border-color: #eea236;}.btn {display: inline-block;padding: 6px 12px;margin-bottom: 0;font-size: 14px; font-weight: 400;line-height: 1.42857143;text-align: center;white-space: nowrap;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer; -webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none; background-image: none; border: 1px solid transparent; border-radius: 4px;}.col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9 {position: relative;min-height: 1px;padding-right: 15px;padding-left: 15px;}.anchoall {width:195px; background-color: #f0ad4e;margin-bottom: 8px;padding: 10px 16px;font-size: 18px;line-height: 1.3333333;border-radius: 6px;border-color: #eea236;}.col-sm-offset-6{margin-left:50%} .navbar-btn { margin-top: 8px; margin-bottom: 8px;margin-left: 510px;}.table>thead>tr>th {vertical-align: bottom; border-bottom: 2px solid #ddd;}</style> \
</head>');
printWindow.document.write(divContents);
printWindow.document.write('</body></html>');
printWindow.document.close();
printWindow.print();
});
</script>
关于html - 使用 angular 2 组件中的 window.print() 将 CSS 类应用于打印窗口的 html 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44841793/
我已经和 Lua 搞了几天,我想出了一些让我三思而后行的事情。 Lua 5.3 的引用手册我还没有看,因为它似乎很复杂,我会尽快查看。 好的,在 lua 5.3 中,我们知道 print() 返回 n
计算时IO (IO ()) , 两个 (IO ())和 ()是计算出来的,所以为什么 main :: IO (IO ()) main = print (print "Hello, World!")
我不太理解从以下位置收到的输出: print(print(print('aaa'))) aaa None None 先aaa清楚了。但我认为第二个 print(aaa) 会抛出一个错误,因为变量 aa
当我运行下面的 Perl one-liner 时,它会打印 1在每一行的前面,我不想要它。它应该做的只是注释匹配 root 的行. $ cat /etc/passwd | perl -ne 'prin
我发现由于 Xcode 将不再消化 println() 我是 留下 Swift.print() 或 print() 。我的问题是, 两者有什么区别?我没能 在网上或在 swift 前卫郎。 (Swif
我正在开发一个内部 Google Chrome 扩展,它需要一种方法来启动将当前页面打印到打印机。我不希望出现默认的打印对话框(因此,javascript:window.print() 是不可能的)。
我正在将 Perl6 Terminal::Print 模块用于基于控制台的应用程序。 它运行良好 - 但是,现在我需要提示用户输入一串文本。 有什么好的方法可以做到这一点? 最佳答案 这是使用 Ter
在学习第三方的Lua代码时,我发现在主脚本文件的顶部 local insert = table.insert local match = string.match local gsub = strin
在学习第三方的Lua代码时,我发现在主脚本文件的顶部 local insert = table.insert local match = string.match local gsub = strin
我目前正在学习 Python,并开始了一个项目,为 2000-2005 年 MLB 摊牌纸牌游戏创建棒球模拟游戏。这些程序包含棒球比赛的事件,作为单独代码段中间的打印语句(“Jeff 击中单打”,“B
我的问题:在没有多余括号的情况下漂亮地打印表达式的最干净的方法是什么? 我有以下 lambda 表达式的表示: Term ::= Fun(String x, Term t) | App(
为了在 Julia 中创建可打印的新类型,应该定义哪些方法?我认为应该只定义 show,然后它将引发其他函数的行为,例如: 打印 字符串 repl_show 显示紧凑 展示 需要为新类型定义以下哪些方
我有一个页面,用户可以在其中打印一些带有图像和数据的 pdf。我希望他们能够打印他们想要的文件数量,并且能够暂停它们——这意味着他们可以停止打印并防止打印尚未发送到打印机的文件;当然,已经发送到打印机
CLHS 说 An attempt to print a circular structure with *print-circle* set to nil may lead to looping
正如标题所示,在 Pycharm 中使用自动完成功能时,显示的唯一自动完成选项是:print(args,kwargs) 内置 我希望自动完成功能以“print”完成,因为这是我通常使用的。我正在使用
是否有可能使用 fmt.Println("...") 打印一个 shell 居中对齐的字符串? 最佳答案 作为对这个长期回答问题的更新,可以通过使用 fmt 包中的 * 符号来改进@miltonb 发
我想在控制台屏幕上显示使用 DO 循环完成的计算进度。我可以像这样将进度变量打印到终端: PROGRAM TextOverWrite_WithLoop IMPLICIT NONE INTEGER ::
我正在尝试为我的新对象定义打印方法,并使用传递给 print 的对象名称。使用 deparse(substitute(y)) .这可以完美地使用 print功能明确: obj function (x
我需要安装 dompdf 方面的帮助。我应该将解压的 zip 文件放在目录中的哪个位置?我按照 INSTALL.txt 进行操作,它显示“将下载的包的内容提取到支持的路径之一”。这是否意味着放入“Mo
我的应用程序中有一个 webkit 小部件,您可以打印它。打印效果很好,除了打印时没有图像,即使屏幕上有图像。 打印代码如下: void MainWindow::printPage() { Q
我是一名优秀的程序员,十分优秀!