3

我一直没有成功尝试打印水平滚动内容。我已经到了厌倦搜索的地步,我想是时候问了——

所以这里是,下面是我要打印的内容的一个非常简化的版本 -

的HTML

<div id="printingDiv">

    <div class='filterRow'>Something long to print#1 Something long to print#2 Something long to print#3 Something long to print#4 Something long to print#5 Something long to print#6 Something long to print#7 Something long to print#8 Something long to print#9 Something long to print#10</div><br/>

    <div class='filterRow'>Something long to print#1 Something long to print#2 Something long to print#3 Something long to print#4 Something long to print#5 Something long to print#6 Something long to print#7 Something long to print#8 Something long to print#9 Something long to print#10</div><br/>

    <div class='filterRow'>Something long to print#1 Something long to print#2 Something long to print#3 Something long to print#4 Something long to print#5 Something long to print#6 Something long to print#7 Something long to print#8 Something long to print#9 Something long to print#10</div><br/>

    <div class='filterRow'>Something long to print#1 Something long to print#2 Something long to print#3 Something long to print#4 Something long to print#5 Something long to print#6 Something long to print#7 Something long to print#8 Something long to print#9 Something long to print#10</div><br/>

</div>

CSS

.printDiv {
     font-size: 12pt; //else the content adjusts its font-size just to fit the print page
     width: auto;
}

.filterRow {
     white-space: no-wrap; //just for the sake of this example, to make sure the content overflows
     width: auto;
}

Javascript

$("#printingDiv").show();
window.print();

输出

在打印输出上 - 我只看到内容,直到Something long to print#5和Something long to print#6的一部分。

我想看到的是Something long to print#6 到Something long to print#10 的其余部分打印在下一页上。

因此,总而言之,我希望能够将不适合第一页的水平滚动内容打印到另一页上。这甚至可能吗?

我提到的一些链接 -

http://alistapart.com/article/goingtoprint

http://meyerweb.com/eric/articles/webrev/200001.html

为具有长水平表格的页面打印样式表- (此链接有一些其他选项,这是唯一的方法吗?)

4

2 回答 2

3

简短而甜蜜:不...

您完全无法控制使用 javascript 打印的方式。您能做的最好的事情就是将“Something long to print#6+ 包装到下一行”。

于 2013-04-03T21:25:26.420 回答
1

从理论上讲,如果您知道将被剪切的副本并将该文本包含在隐藏在屏幕上但在打印时可见的块中,您就可以做到。

<div class="noWrapContent">This is a long piece of text that stops here. This is the text that would be cut off.</div>
<div class="forPrint">This is the text that would be cut off.</div>

然后在 css 中:

.forPrint { display: none; }

@media print { display: block;}

但是,总的来说,您应该在打印时将其包裹起来。

于 2013-04-04T20:28:09.717 回答