NAME
Metacode::Reader - parse Xerox Metacode data
SYNOPSIS
use Metacode::Reader 'translate_file';
open METACODE, 'source.met' or die "Can't open source.met: $!";
$metacode = do { local $/ = undef; <METACODE> };
$parse = translate_file( \$metacode );
print $$parse;
ABSTRACT
Perl module for translating Xerox's binary data format printer file format into a human readable format.
EXPORT
None by default.
DESCRIPTION
The Xerox Metacode format is fed directly to Xerox Enterprise Printing Systems (EPS) for large volumn print jobs. The format is unpublished and this module only handles part of the decoding task. You will have to continue the reverse engineering effort if you want to get positional or drawing characters to appear.
The output from this function should be further massaged into whatever format is convenient for you.
PUBLIC METHODS
- $ref = translate_file( \$binary_file )
-
Pass in a scalar reference to the entire Metacode binary file and you'll be given a scalar reference to the parsed output.
- $ref = translate_record( \$record, $sourceFilePosition, \@fonts )
-
Pass in a scalar reference to the binary Metacode record, the current offset into the Metacode file and a fonts array. The file position is used for error reporting in case any problems show up. The fonts array is used for when DJDE records set the current operational fonts so further translate_record() calls can use the font names.
PARSED OUTPUT FORMAT
The output consists of a single string. Internally each metacode command is ended by a single newline. Each record is also further ended by another newline. I used this non-traditional format to avoid costs associated with array allocation. The most natural format for this would have been to return a single array for the entire file where each element is an array ref for each metacode record. So... It's a comprimise. The newline character itself is not valid text so there is no concern about embedded newlines altering the parse.
FontSwitch 0 ?
DJDE FONTS UN104B HE18BP HE06NP HE08OP
EndOfLine
FontSwitch 0 UN104B
Positional 6 1223
Positional 4 3461
FontSwitch 10 BLANKP
Text LONG_TERM
EndOfLine
FontSwitch 0 UN104B
Positional 6 1179
Positional 4 3461
FontSwitch 10 BLANKP
Text XXNAME:foo
EndOfLine
- Text
-
'Text ' followed by the text
- DJDE FONTS
-
'DJDE FONTS ' followed by a list of font names.
- DJDE IMAGE
-
'DJDE IMAGE ' followed by the image filename
- DJDE END
-
'DJDE END' indicates the end (and activation) of any pending DJDE sequences.
- FontSwitch
-
'FontSwitch # fontname' If the font number can be matched back to a name then the font name is returned as well.
- EndOfLine
-
'EndOfLine' This occurs at the end of Metacode records.
- Orientation
-
'Orientation #' Portrait / Landscape
- Positional
-
'Positional # ###' Seek to this location on the page. This must be further explored to make it useful.
- Drawing
-
'Drawing ## C' Display a drawing character. This is usually in a symbols font.
- The codes 9 through 31
-
I have no idea.
- ERROR
-
This indicates an error occured in the parse.
METACODE FORMAT
A metacode file is separated into a series of contiguous records. Each record consists of a two byte length value and the remainder is Metacode. The first part of the Metacode is typically a font setting (to zero) and then a control character. This can be ignored for most work. The following string demonstrates the record format. Note that the two byte length value includes itself so a record with length 3 is likely to simply be "\00\03\01".
The actual printer codes aren't fully understood yet though if you need more detail just examine this module's source code.
METACODE EXAMPLE
This is an example of a complete Metacode record complete with header, body and tail.
"\00\11" . # record length - 17 bytes
"\00\00+" . # FontSwitch 0 and control character
"\02" . # a command
"\06\00\04".# ''
"\04\00\04".# ''
"Text". # printable data
"\01"; # end of record
SEE ALSO
nntp://comp.sys.xerox http://www.xerox-techsupport.com/
BUGS
Correctly parses text records - you cannot render images from the current module. Further reverse engineering is required to get that.
I no longer have access to Xerox Metacode data and cannot create tests.
AUTHOR
Joshua b. Jore <jjore@cpan.org>
COPYRIGHT AND LICENSE
Copyright 2003, Joshua b. Jore. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of either:
a) the GNU General Public License as published by the Free Software Foundation; version 2, or
b) the "Artistic License" which comes with Perl.