|
NAMEPostScript::PPD - Read PostScript Printer Definition filesSYNOPSISuse 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; ABSTRACTPostScript::PPD reads and parses PostScript Printer Definition files, called PPDs.DESCRIPTIONPostScript::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>. SchemaA 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 METHODSnewmy $ppd = PostScript::PPD->new; my $ppd = PostScript::PPD->new( $ppdfile ); Create the object, optionally loading $ppdfile. load$ppd->load( $ppdfile ); Load a PPD file. parse$ppd->parse( $text ); Parses a PPD as a string. Uses "\n" as line sepperators. getmy $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"AUTOLOAD" is used to implement accessor methods for all keys in the PPD.Groupsmy @groups = $ppd->Groups; my $arrayref = $ppd->Groups; Returns a list of available groups, in the order they are defined in the PPD. Groupmy $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 ); PostScript::PPD::SubkeyA "PostScript::PPD::Subkey" represents a group of UI options, a single UI option, or the value of one UI option key.getGet a key from this subkey. Itself returning either a "PostScript::PPD::Subkey" or a simple scalar.AUTOLOADmy $text = $PageSize->Letter Syntatic sugar for my $text = $PageSize->get( 'Letter' ); as_stringprint "$subkey"; print $subkey->get('value')||$subkey; A PPD subkey will stringies to it's "value". nameReturns the name of this UI group, option or key.defaultGet the default value for this UI option. That is, for option PageSize, returns the option PageSizeBDefault.textReturns the text you will want to display.UIsGet a list of all UI options in a group.UIGet a single UI option from a group.listReturns a list of all values for this UI option.sorted_listReturns a list of all values for this UI option, sort by their "text".DumpHandy method to dump out the object. Because Data::Dumper will print the entire PPD.SEE ALSONet::CUPSAUTHORPhilip Gwyn, <gwyn-at-cpan.org>COPYRIGHT AND LICENSECopyright (C) 2008-2020 by Philip GwynThis 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.
Visit the GSP FreeBSD Man Page Interface. |