This Question is Answered

13 "helpful" answers available (5 pts)
7 Replies Last post: Dec 10, 2009 7:54 PM by anujinka  
anujinka Level 6 73 posts since
Sep 16, 2008
Currently Being Moderated

Dec 9, 2009 9:49 PM

Printer handling

Can we change printer settings from simple to double-side (two-side) print from curl?

If possible please some advice or sample source.

 

Plus some things want to tell. Why curl is so weak for printer? Because of now we can't change paper size and two-sided print ... direct from curl, we just using old VB to set printer settings.

Deng Tian Level 6 56 posts since
Oct 17, 2007
Currently Being Moderated
1. Dec 9, 2009 11:25 PM in response to: anujinka
Re: Printer handling

I don't think you could set some advanced settings like double-side printing.

But you do be able to set paper size through print-graphic with the option page-description ( this option is supported from Curl RTE version 6.0).

The reason some advanced settings are not supported I guess, is that they depends on hardware (printers), Some features are provided by drivers from hardware vendor, which could not or very hard  be accessed through standard API from  OS.

Robert Shiplett MVP 197 posts since
Oct 17, 2007
Currently Being Moderated
2. Dec 10, 2009 3:43 PM in response to: anujinka
Re: Printer handling

For Microsoft app's this is often a matter of wrapping a DLL.  They have some advice at

   http://msdn.microsoft.com/en-us/library/ms801250.aspx

When I used to do printer app's in Smalltalk we did our own C DLL's - I don't know how much life has changed under MS .net    The modern Dolphin Smalltalk has an excellent example and there is a DLL kit for VW Smalltalk that can be a help to see the approach if you have not done C or C++.  At least we have escaped parallel and serial ports in most of MS-land ...  I see this note at

   http://www.codeproject.com/KB/dotnet/NET_Printer_Library.aspx

 

I haven't deployed anything for Mac since about '98 ...   Cocoa may have added a higher level for Objective-C.

 

Linux is more straightforward as I/O specifics was not part of the C language spec - and I/O was the weakpoint of Intel PC design ... and mainframe graphics lessons were ignored in the MS GDI.

 

Here is a linux HOWTO

   http://www.faqs.org/docs/Linux-HOWTO/Printing-HOWTO.html

 

When I worked on industrial printer app's we were in distributed Smalltalk (CORBA) with any kind of printer you can imagine in any sequence (multiple format printers per single workflow task) - you learn to hate printers or discover that maybe you should have been an actuary ...

 

Hope you find the DLL stuff in the Curl doc's helpful.  An external library project has appeared on sourceforge.

 

You might want to look at ActiveX as your component approach if this is Windows issue - and in that case there is a good deal of info on the internet and Curl plays well with ActiveX.

 

If you have used Gtk with another language such as Python, there is a Gtk::Printer to look into.

 

I don't see handling printers as a Curl language weakness as prior to USB this was just interrupt controllers and the hardware and its drivers.  As a web-content language, it is not surprising that we leave printing to the browser or to the ubiquitous Crystal Reports - but as a desktop app for RIA, well, there Curl has a project underway (I suspect).  I am following the efforts of another web language, Rebol3, to remain cross-platform + PITL modular + UNICODE at this very moment.  Not a simple matter.  Unless your language capitulates to DOT net, for example ( and just where is IronPython these days ? ;-)

Robert Shiplett MVP 197 posts since
Oct 17, 2007
Currently Being Moderated
3. Dec 10, 2009 3:49 PM in response to: Robert Shiplett
Re: Printer handling

Here's the Java SDK side - but it is very optimistic, as with printers, the devil is indeed in the details.

   http://java.sun.com/javase/6/docs/technotes/guides/jps/spec/jpsOverview.fm3.html

Robert Shiplett MVP 197 posts since
Oct 17, 2007
Currently Being Moderated
4. Dec 10, 2009 3:52 PM in response to: Robert Shiplett
Re: Printer handling

Curl docs say:  On Linux platforms, the Curl RTE uses CUPS for printing. Please visit LinuxPrinting.org CUPS Quick Start for more information.

Robert Shiplett MVP 197 posts since
Oct 17, 2007
Currently Being Moderated
5. Dec 10, 2009 4:02 PM in response to: Robert Shiplett
Re: Printer handling

This is the doc for print-graphic

 

print-graphic (proc)


public 
{print-graphic
    graphic:Graphic,
    left-margin:Distance = {Printer.get-page-setup-margin}.left-offset,
    right-margin:Distance = {Printer.get-page-setup-margin}.right-offset,
    top-margin:Distance = {Printer.get-page-setup-margin}.top-offset,
    bottom-margin:Distance = {Printer.get-page-setup-margin}.bottom-offset,
    unprintable-margin-padding:Distance = 2.0pt,
    nw-title:#Visual = null,
    nw-title-font-size:Distance = 7.0pt,
    ne-title:#Visual = null,
    ne-title-font-size:Distance = 7.0pt,
    print-page-numbers?:bool = true,
    page-number-font-size:Distance = 7.0pt,
    print-date?:bool = true,
    date-font-size:Distance = 7.0pt,
    hstretch?:bool = false,
    vstretch?:bool = false,
    paginate?:bool = true,
    multi-part?:bool = false,
    printing-frame:#PrintRootFrame = null,
    show-printer-dialog?:bool = true,
    from-page:int = 1,
    to-page:int = max-int,
    orientation:PageOrientation = PageOrientation.default,
    owner:#View = {View.get-default-owner},
    printer-name:#String = null,
    page-description:#PrintPageDescription = null,
    copies:int = 0
}:#PrintRootFrame

 

Note that PrintPageDescription class (Curl 6) has height and width.

 

Even a PrintJob class in another language's framework may not have double-sided or gray-scale or anything else related to warnings such as low paper or low ink/toner which have to do with printer properties and printer state - which are usually exposed via an API for some driver.

Robert Shiplett MVP 197 posts since
Oct 17, 2007
Currently Being Moderated
6. Dec 10, 2009 4:05 PM in response to: Robert Shiplett
Re: Printer handling

Here is a link to some StackOverflow notes on the dot NET side for POS printing

 

  http://stackoverflow.com/questions/187465/drive-a-pos-printer-via-usb-in-c

More Like This

  • Retrieving data ...