GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
PostScript::PPD(3) User Contributed Perl Documentation PostScript::PPD(3)

PostScript::PPD - Read PostScript Printer Definition files

    use PostScript::PPD;

    my $ppd = PostScript::PPD->new( $file );

    print "Maker: ", $ppd->Manufacturer, "\n", 
          "Mode: ", $ppd->ModelName;

    # Also:
    print "Maker: ", $ppd->get( 'Manufacturer' ), "\n", 
          "Mode: ", $ppd->get( 'ModelName' );

    # Get a list of UI groups
    my @groups = $ppd->Groups;

    # Get one UI group
    my $G = $ppd->Group( $groups[0] );

    # Get a list of UI options in that group
    my @UIs = $G->UIs;
    
    # Get one UI option
    my $ui = $G->UI( $UIs[0] );

    print "Default $groups[0] $UIs[0]: ", $ui->default;

PostScript::PPD reads and parses PostScript Printer Definition files, called PPDs.

PostScript::PPD reads and parses PostScript Printer Definition files, called PPDs.

PPDs contain key/value tuples that describe the printer, its capabilities and the printing options available. The printing options are classified as User Interface (UI) options, which are grouped into groups.

I huge database of PPDs is available from <http://www.linuxfoundation.org/en/OpenPrinting/Database/Foomatic>.

A PPD is a series of key/value pairs in two groups. The first group provides information about the printer and some of its features. The second group describe all the options that the PPD provides, as well as an organised UI for setting them. This UI is organised into a hierarchy :

    Group1
        Option1 
            key1: value
            key2: value
        Option2
            key1: value
            key2: value
    Group2
        OtherOption1 
            key1: value
            key2: value

A value can be a block of PostScript, to be executed on the printer, or a value to be passed to "lp -o".

Very simple example:

    *OpenGroup: General/General
    *OpenUI *PageSize/Page Size: PickOne
    *OrderDependency: 100 AnySetup *PageSize
    *DefaultPageSize: Letter
    *PageSize Letter/US Letter: "<</PageSize[612 792]/ImagingBBox null>>setpagedevice"
    *CloseGroup: General

So if you wanted to use "US Letter" sized paper, you would use the following command:

    lp -o PageSize=Letter

    my $ppd = PostScript::PPD->new;
    my $ppd = PostScript::PPD->new( $ppdfile );

Create the object, optionally loading $ppdfile.

    $ppd->load( $ppdfile );

Load a PPD file.

    $ppd->parse( $text );

Parses a PPD as a string. Uses "\n" as line sepperators.

    my $value = $ppd->get( $name );
    my $value = $ppd->get( $name, $subkey );
    
    my $value = $ppd->$name();
    my $value = $ppd->$name( $subkey );

Returns one value from the PPD.

    my $ps = $ppd->CustomPageSize( 'True' );
    my $ps = $ppd->get( 'CustomPageSize', 'True' );

No, this doesn't set the CustomPageSize to True; it returns the PostScript needed by the printer to set CustomPageSize to True.

The value returned is a "PostScript::PPD::Subkey" object or a simple string for information keys.

"AUTOLOAD" is used to implement accessor methods for all keys in the PPD.

    my @groups = $ppd->Groups;
    my $arrayref = $ppd->Groups;

Returns a list of available groups, in the order they are defined in the PPD.

    my $group = $ppd->Group( $groupname );

Returns one UI option group named $groupname. An option group would be displayed as one tab in the printer configuration widget.

Syntatic sugar for

    my $group = $ppd->get( group => $groupname );

A "PostScript::PPD::Subkey" represents a group of UI options, a single UI option, or the value of one UI option key.

Get a key from this subkey. Itself returning either a "PostScript::PPD::Subkey" or a simple scalar.

    my $text = $PageSize->Letter

Syntatic sugar for

    my $text = $PageSize->get( 'Letter' );

    print "$subkey";
    print $subkey->get('value')||$subkey;

A PPD subkey will stringies to it's "value".

Returns the name of this UI group, option or key.

Get the default value for this UI option. That is, for option PageSize, returns the option PageSizeBDefault.

Returns the text you will want to display.

Get a list of all UI options in a group.

Get a single UI option from a group.

Returns a list of all values for this UI option.

Returns a list of all values for this UI option, sort by their "text".

Handy method to dump out the object. Because Data::Dumper will print the entire PPD.

Net::CUPS

Philip Gwyn, <gwyn-at-cpan.org>

Copyright (C) 2008-2020 by Philip Gwyn

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

2020-11-06 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.