通过记事本横向打印文本
我正在尝试在 Windows 上进行一些基于文本的打印。 我的程序利用 Windows 的“notepad /p file.txt
”功能在默认打印机上打印文本文件。
问题是你不能说你想以横向打印而不是纵向打印。 同样,也无法打印到另一台打印机。
有关于此的一些背景信息:我正在打印 Tcl/Tk 程序(请参阅 The Tcl'ers wiki on text打印)。 我可以使用 GDI 进行打印,但由于某种原因,这太慢了,并且我想提供文本打印作为快速替代方案,因为打印到文本文件已经可用。
I'm trying to do some text-based printing on Windows. My program makes use of windows' "notepad /p file.txt
" functionality that prints a text file on the default printer.
The problem is that you cannot say that you want to print in landscape instead of portrait. In the same way, it's not possible to print to another printer.
Some background information on this: I'm printing out of a Tcl/Tk program (see The Tcl'ers wiki on text printing). I can print using the GDI, but for some reason this is too slow, and I want to offer text printing as a fast alternative as print to a text file is already available.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试这个免费软件程序。 它是有益的。
http://home.swipnet.se/~w-62144/prfile/ descr.htm
要为某些文本打开打印机对话框,请执行以下操作。
如果您无法使用可执行文件,请使用 printui.dll。
您必须枚举机器上的打印机,然后传递您想要使用的打印机的字符串
下面将显示特定打印机的打印首选项对话框
然后您可以致电
我认为免费软件路线要容易得多,因为您不这样做不需要发现默认打印机,询问用户并以非标准方式打印文件。
编辑我忘记添加 rundll32.exe 部分来调出打印机首选项
You can try this freeware program. It is useful.
http://home.swipnet.se/~w-62144/prfile/descr.htm
To bring up a printer dialog for some text do something like this
If you can't use an executable, Use printui.dll.
You will have to enumerate the printers on the machine, then pass the string of the printer you wish to use
The following will show the print perferences dialog for a specific printer
You could then call
I think the freeware route is much easier as you don't need to discover the default printer, ask the user and print the file in a nonstandard way.
EDIT I forgot to add the rundll32.exe part to bring up printer preferences
可以帮助您:
http://torisugari.googlepages.com/commandlineprint2
允许命令行打印的 Firefox 扩展。 它似乎不支持传递方向参数,但我想可以添加对其的支持。
编辑
我刚刚重新阅读了扩展页面:它使用用户配置文件的默认首选项,因此如果您将其设置为默认横向打印,则扩展应该尊重该设置。
当然,此选项会强制您的用户安装 Firefox 和此扩展。
或许不是最好的选择...
Something that could help you:
http://torisugari.googlepages.com/commandlineprint2
A Firefox extension that allows command-line printing. It does not seem to support passing orientation parameter, but I guess that it would be possible to add support for it.
EDIT
I just re-read the extension page: it uses the default preference of the user profile, so if you set it up as having landscape printing by default, the extension should respect that setting.
Of course, this option would force your users to install both Firefox and this extension.
Might not be the best choice...
搜索Google后,似乎记事本没有其他命令行选项。 此外,
print
命令似乎并未采用横向打印的替代选项。 我曾希望这与(大写的“P”)不同,
但显然不是,所以看起来你不走运。 我能想到的唯一建议是看看是否有办法从命令行设置打印默认值,然后再将它们切换回来。 我不知道这是否可能。
编辑1:可能有帮助的东西:http://www.robvanderwoude.com /2kprintcontrol.php。
编辑2:看起来这不会控制打印首选项,只能控制打印机本身,因此您必须找到另一种方法。
After searching Google, it appears that there are no other command line options for notepad. Also, the
print
command doesn't appear to take alternate options for landscape printing. I had hoped thatwas different than
(a capital 'P') but apparently not, so it looks like you are out of luck. The only suggestion I can come up with is see if there is a way to set the printing defaults from the command line, then switch them back afterwards. I have no idea if this is possible though.
Edit 1: Something that MIGHT help: http://www.robvanderwoude.com/2kprintcontrol.php.
Edit 2: Looks like this won't control the printing preferences, just the printers themselves, so you'll have to find another method.