|
| 14 Sep |
|
| 23 Apr |
|
| 2 Jul |
|
| 18 May |
|
| 27 Jan |
|
| 17 Jan |
|
| 17 Jan |
|
| 17 Jan |
|
| 17 Jan |
|
| 12 Oct |
|
An EncoderThe procedure labelled code2of5 is a simple example of an encoder, which we will now consider. Its purpose is to accept as input a string containing the barcode contents and a string containing a list of options, and to process these in a way that is specific to this encoder, and finally to output an instance of the dictionary-based data structure described in section 2.1 that represents the barcode contents in the Code 2 of 5 symbology. As with all of the encoders, the input string is assumed to be valid for the corresponding symbology, otherwise the behaviour is undefined. The variables that we use in this procedure are confined to local scope by declaring the procedure as follows: /code2of5 {
We start by immediately reading the contents strings that are passed as arguments to this procedure by the user. We duplicate the options string because it is later passed unamended to the renderer. /options exch def We initialise a few default variables. Those variables corresponding to options that can be enabled with the options argument are initially set to false. /includetext false def The options string is tokenised with each successive token defining either a name value pair which we instantiate or a lone variable that we define as true, allowing us to override the given default variables given above. options {
Since any user given options create variables that are strings we need to convert them back to their intended types. /textfont textfont cvlit def We then create an array of string encodings for each of the available characters which we then declare in another string. This information can be derived from careful reading of the relevant specification, although this is often surprisingly difficult to obtain. /encs We now store the length of the content string and calculate the total number of bars and spaces in the resulting barcode. We initialise a string of size dependant on this length into which we will build the space bar succession. Similarly, we create an array into which we will add the human readable text information. /barlen barcode length def We now begin to populate the space bar succession by adding the encoding of the start character to the beginning. sbs 0 encs 10 get putinterval We now enter the main loop which iterates over the content string from start to finish, looking up the encoding for each character, adding this to the space bar succession. It is important to understand how the encoding for a given character is derived. Firstly, given a character, we find its position in the string of all available characters. We then use this position to index the array of character encodings to obtain the encoding for the given character, which is added to the space/bar succession. Likewise, the character is added to the array of human readable text along with positioning and font information. 0 1 barlen 1 sub {
The encoding for the end character is obtained and added to the end of the space bar succession. sbs barlen 10 mul 6 add encs 11 get putinterval Finally we prepare to push a dictionary containing the space bar succession (and any additional information defined in section 2.1) that will be passed to the renderer. /retval 1 dict def
|
|
| Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy |
| ©2008 Google |