我在javascript中做这样的事情,点击链接打印我的页面的一部分
function printDiv() {
var divToPrint = document.getElementById('printArea');
var newWin = window.open();
newWin.document.write(divToPrint.innerHTML);
newWin.print();
newWin.close();
}
Run Code Online (Sandbox Code Playgroud)
它在Firefox中很好用,但在IE中却不行.
请有人帮忙
我有一个页面应该启动打印预览页面onload.
我找到了这个:
var OLECMDID = 7;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 1 - open window
* 4 - Save As
*/
var PROMPT = 1; // 2 DONTPROMPTUSER
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
Run Code Online (Sandbox Code Playgroud)
但...
有没有更好的方式为IE或适用于FireFox的方式?
为什么这个Ruby对象to_s和inspect看起来做同样事情的方法?
该p方法调用inspect并放置/打印to_s用于表示对象的调用.
如果我跑
class Graph
def initialize
@nodeArray = Array.new
@wireArray = Array.new
end
def to_s # called with print / puts
"Graph : #{@nodeArray.size}"
end
def inspect # called with p
"G"
end
end
if __FILE__ == $0
gr = Graph.new
p gr
print gr
puts gr
end
Run Code Online (Sandbox Code Playgroud)
我明白了
G
Graph : 0
Graph : 0
Run Code Online (Sandbox Code Playgroud)
to_s和之间有什么区别inspect?puts,print以及p?如果我注释掉 …
这是基本前提:
我的用户点击了一些小玩意儿,一个PDF文件被吐出到他的桌面上.我有办法将此文件发送到打印机队列并将其打印到本地连接的打印机吗?
string filePath = "filepathisalreadysethere";
SendToPrinter(filePath); //Something like this?
Run Code Online (Sandbox Code Playgroud)
他会多次这样做.对于教室里的每个学生,他必须打印一张小型成绩单.所以我为每个学生生成一个PDF,我想自动化打印过程,而不是让用户生成pdf,打印,生成pdf,打印,生成pdf,打印.
有关如何处理此问题的任何建议?我在Windows XP上使用Windows Forms .NET 4运行.
我发现这个StackOverflow问题,其中接受的答案表明:
创建文件后,可以通过命令行打印它们(可以使用System.Diagnostics命名空间中的Command类)
我怎么做到这一点?
我想从函数本身内部打印python函数的docstring.例如.
def my_function(self):
"""Doc string for my function."""
# print the Docstring here.
Run Code Online (Sandbox Code Playgroud)
目前我my_function在定义之后直接这样做.
print my_function.__doc__
Run Code Online (Sandbox Code Playgroud)
但宁愿让函数自己这样做.
我已经打过电话print self.__doc__ print self.my_function.__doc__和print this.__doc__内部创建my_function但这并没有工作.
如何在R中使用新行字符?
myStringVariable <- "Very Nice ! I like";
myStringVariabel <- paste(myStringVariable, "\n", sep="");
Run Code Online (Sandbox Code Playgroud)
上面的代码不起作用
PS搜索这种东西时存在重大挑战,因为查询"R new line character"似乎确实混淆了google.我真的希望R有一个不同的名字.
我正在尝试打印我的应用程序的特定部分.
该应用程序有一个用户列表,显示他们的名字和姓氏.当我点击一个用户时,我会得到一个包含更多详细信息的弹出窗口.
如何为我点击的用户打印弹出窗口?弹出窗口如下所示:
<div id="user<?=$user->id;?>" class="popup">
<div class="details">
User details...
</div>
<a href="#print">Print</a>
</div>
Run Code Online (Sandbox Code Playgroud)
但是打印按钮还没有工作.
我搜索了Google,Stack Overflow和我的Python用户指南,但没有找到一个简单,可行的答案.
我在Windows 7 x64计算机上创建了一个文件c:\ goat.txt,并尝试将"test"打印到该文件.我根据StackOverflow上提供的示例尝试了以下内容:
此时我不想使用日志模块,因为我从文档中无法理解基于二进制条件创建简单日志.打印很简单但是如何重定向输出并不明显.
一个简单明了的例子,我可以进入我的interperter是最有帮助的.
此外,赞赏任何信息网站的建议(不是pydocs).
import sys
print('test', file=open('C:\\goat.txt', 'w')) #fails
print(arg, file=open('fname', 'w')) # above based upon this
print>>destination, arg
print>> C:\\goat.txt, "test" # Fails based upon the above
Run Code Online (Sandbox Code Playgroud) 这是我的代码
<script>
var body = "dddddd"
var script = "<script>window.print();</scr'+'ipt>";
var newWin = $("#printf")[0].contentWindow.document;
newWin.open();
newWin.close();
$("body",newWin).append(body+script);
</script>
<iframe id="printf"></iframe>
Run Code Online (Sandbox Code Playgroud)
这可以,但它打印父页面,我如何让它只打印iframe?
有没有办法阻止函数调用print?
我正在使用该pygame.joystick模块进行我正在进行的游戏.
我创建了一个pygame.joystick.Joystick对象,并在游戏的实际循环中调用其成员函数get_button来检查用户输入.该功能完成了我需要它做的所有事情,但问题是它也会调用print,这会大大减慢游戏速度.
我可以阻止这个电话print吗?