printer-driver
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:Printer driver for REBOL, supports Windows and UNIX (through CUPS)
printer-driver
==============

Printer driver for REBOL, supports Windows and UNIX (through CUPS), so it runs fine both on Linux and MacOS X too.

Requirements
------------

You need REBOL/View and /Library component in order to use this driver.

How to use it?
--------------

If you have cloned locally this repository, enter the repo and just do it!

    do %printer-scheme.r
	
Alternatively, you can also install it from network when needed:

    do https://raw.github.com/dockimbel/printer-driver/master/printer-scheme.r

The driver installs a new printer:// scheme. Usage is then pretty simple:

    write printer:// 
or

    write/custom printer://  []
    
     are:
        printer ""	: use a specific printer instead of default one
        doc-name ""  : give a title to the document
        
It is also possible to list all the printers available using:

    printer/enum
    
for example, from the console:

    >> probe printer/enum
    [
        "Samsung ML-1670 Series" [none local]
        "Microsoft XPS Document Writer" [none local]
        "Microsoft Office Document Image Writer" [none local]
        "Lexmark 3500-4500 Series" [none local]
        "Fax" [none local]
        "EcoFax" [none local]
        "Bullzip PDF Printer" [none local]
    ]
    
Note: it would be nicer if we would use `get-modes` on the port to retrieve that instead of tapping directly into the global `printer` context. It's just a few more lines of code, any taker? :-)

The additional block after each string is for storing some flags. `local` or `remote` flags are used to indicate if the printer is locally connected or on a remote computer. You can then use one of the string name reported here as argument to `printer` option described above. Please `copy` this block and strings if you need to modify them (it's just an internal data structure exposed).

In order to print multiple pages, or to stream pages to printer one by one, it is possible to manually operate the printer port:

    p: open printer://
	insert p 'start-doc		; declare a new document to print
	
	insert p 'start-page	; open a new page
	insert p page1			; print content of the page 1
	insert p 'end-page		; close page
	
	insert p 'start-page	; open a new page
	insert p page2			; print content of the page 2
	insert p 'end-page		; close page

	insert p 'end-doc		; flush all to printer and close document to print
    close p					; close printer port
    
In case you want to hack something in the driver, you can start by looking at the platform-specific `locals` object!, especially `caps` and `scale` properties:

    p: open printer://
    probe p/locals
    close p

How to create a document to print?
----------------------------------

The format used for describing documents used by the printer scheme is the [DRAW](http://www.rebol.com/docs/draw.html) dialect, or rather a subset of it. Only the following DRAW commands are accepted:

    text
    line
    line-width
    box
    arc
    font
    pen
    fill-pen
    image
   
An addition has been made to the dialect for specifying a custom area of multiple lines of text: 

    text-box <text> <position> <size>
    
    <text>     : string! value, text to print, wrapping on newline markers
    <position> : pair! value, position of left top corner of the text area
    <size>     : pair! value
 
Note 1: The syntax for `text` command is reversed compared to Draw dialect:
	
    text <text> <position>


Note 2: I can't remember why I haven't used the more common `area` word instead of `text-box`...

Simple Example
--------------

    write printer:// [
    	pen blue
    	text "Hello World!" 100x100
    ]


A complete example can be found in the tests/ folder.

License
-------

[BSD](http://www.opensource.org/licenses/bsd-3-clause) license.


Enjoy!</pre>  <br />
		
		
		</div>
		<!-- detail content end -->

		<div class="ad_footer">
			
				<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 728x90, 创建于 11-8-29 -->
<ins class="adsbygoogle"
     style="display:inline-block;width:728px;height:90px"
     data-ad-client="ca-pub-9609188192387119"
     data-ad-slot="4736870470"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
				
			
		</div>


		<!-- file list begin -->
		<div class="detail_file">
			<div class="menu1_left">
				<div class="menu1_right">
					<div class="menu1_txt">部分文件列表(点击文件名可查看文件内容)</div>
			  </div>
			</div>
			
			<div id="file_content">
					<!--div class="ad_footer">
					</div-->

									本源码包内暂不包含可直接显示的源代码文件,请下载源码包。
							</div>
		</div>
		<div class="clear"></div>
		<!-- file list end -->

			</div>
	<!-- content_right end -->
	<div class="clear"></div>
</div>
<!-- content end -->
	
<!-- footer begin -->
<div id="footer">
  <div id="footer_content">
    <div id="contact">联系我们:verysource_com<img src="/images/character/m_a_i_l.gif" width="51" height="12" align="absmiddle" /></div>
    <div id="copy_right">CopyRight © 2008-2022 verySource.Com All Rights reserved. <a target="_blank" rel="nofollow" href="https://beian.miit.gov.cn/" style="color:#66FFFF; font-size:14px;">京ICP备17048824号-1</a> 京公网安备:11010502034788</div>
  </div>
</div>
<div style="display:none;">
	
	<script>
	var _hmt = _hmt || [];
	(function() {
	  var hm = document.createElement("script");
	  hm.src = "https://hm.baidu.com/hm.js?9c89b037e07a1dbd53937515a5761041";
	  var s = document.getElementsByTagName("script")[0]; 
	  s.parentNode.insertBefore(hm, s);
	})();
	</script>
	
</div>
<!-- footer end -->
</body>
</html>