git ssb

0+

cel / freecheck



Commit 6100c2a5d781d1ac261195db53af7fa6685e1e10

commit from v0.1 tarball

Caleb Maclennan committed on 3/10/2014, 9:03:38 PM

Files changed

AUTHORSadded
COPYINGadded
ChangeLogadded
Newsadded
READMEadded
TODOadded
example_check.psadded
freecheck.cfgadded
freecheck.pladded
AUTHORSView
@@ -1,0 +1,4 @@
1 +freecheck is written by:
2 +
3 +Eric Sandeen <eric_sandeen@bigfoot.com>
4 +
COPYINGView
@@ -1,0 +1,340 @@
1 + GNU GENERAL PUBLIC LICENSE
2 + Version 2, June 1991
3 +
4 + Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5 + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 + Everyone is permitted to copy and distribute verbatim copies
7 + of this license document, but changing it is not allowed.
8 +
9 + Preamble
10 +
11 + The licenses for most software are designed to take away your
12 +freedom to share and change it. By contrast, the GNU General Public
13 +License is intended to guarantee your freedom to share and change free
14 +software--to make sure the software is free for all its users. This
15 +General Public License applies to most of the Free Software
16 +Foundation's software and to any other program whose authors commit to
17 +using it. (Some other Free Software Foundation software is covered by
18 +the GNU Library General Public License instead.) You can apply it to
19 +your programs, too.
20 +
21 + When we speak of free software, we are referring to freedom, not
22 +price. Our General Public Licenses are designed to make sure that you
23 +have the freedom to distribute copies of free software (and charge for
24 +this service if you wish), that you receive source code or can get it
25 +if you want it, that you can change the software or use pieces of it
26 +in new free programs; and that you know you can do these things.
27 +
28 + To protect your rights, we need to make restrictions that forbid
29 +anyone to deny you these rights or to ask you to surrender the rights.
30 +These restrictions translate to certain responsibilities for you if you
31 +distribute copies of the software, or if you modify it.
32 +
33 + For example, if you distribute copies of such a program, whether
34 +gratis or for a fee, you must give the recipients all the rights that
35 +you have. You must make sure that they, too, receive or can get the
36 +source code. And you must show them these terms so they know their
37 +rights.
38 +
39 + We protect your rights with two steps: (1) copyright the software, and
40 +(2) offer you this license which gives you legal permission to copy,
41 +distribute and/or modify the software.
42 +
43 + Also, for each author's protection and ours, we want to make certain
44 +that everyone understands that there is no warranty for this free
45 +software. If the software is modified by someone else and passed on, we
46 +want its recipients to know that what they have is not the original, so
47 +that any problems introduced by others will not reflect on the original
48 +authors' reputations.
49 +
50 + Finally, any free program is threatened constantly by software
51 +patents. We wish to avoid the danger that redistributors of a free
52 +program will individually obtain patent licenses, in effect making the
53 +program proprietary. To prevent this, we have made it clear that any
54 +patent must be licensed for everyone's free use or not licensed at all.
55 +
56 + The precise terms and conditions for copying, distribution and
57 +modification follow.
58 +
59 + GNU GENERAL PUBLIC LICENSE
60 + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 +
62 + 0. This License applies to any program or other work which contains
63 +a notice placed by the copyright holder saying it may be distributed
64 +under the terms of this General Public License. The "Program", below,
65 +refers to any such program or work, and a "work based on the Program"
66 +means either the Program or any derivative work under copyright law:
67 +that is to say, a work containing the Program or a portion of it,
68 +either verbatim or with modifications and/or translated into another
69 +language. (Hereinafter, translation is included without limitation in
70 +the term "modification".) Each licensee is addressed as "you".
71 +
72 +Activities other than copying, distribution and modification are not
73 +covered by this License; they are outside its scope. The act of
74 +running the Program is not restricted, and the output from the Program
75 +is covered only if its contents constitute a work based on the
76 +Program (independent of having been made by running the Program).
77 +Whether that is true depends on what the Program does.
78 +
79 + 1. You may copy and distribute verbatim copies of the Program's
80 +source code as you receive it, in any medium, provided that you
81 +conspicuously and appropriately publish on each copy an appropriate
82 +copyright notice and disclaimer of warranty; keep intact all the
83 +notices that refer to this License and to the absence of any warranty;
84 +and give any other recipients of the Program a copy of this License
85 +along with the Program.
86 +
87 +You may charge a fee for the physical act of transferring a copy, and
88 +you may at your option offer warranty protection in exchange for a fee.
89 +
90 + 2. You may modify your copy or copies of the Program or any portion
91 +of it, thus forming a work based on the Program, and copy and
92 +distribute such modifications or work under the terms of Section 1
93 +above, provided that you also meet all of these conditions:
94 +
95 + a) You must cause the modified files to carry prominent notices
96 + stating that you changed the files and the date of any change.
97 +
98 + b) You must cause any work that you distribute or publish, that in
99 + whole or in part contains or is derived from the Program or any
100 + part thereof, to be licensed as a whole at no charge to all third
101 + parties under the terms of this License.
102 +
103 + c) If the modified program normally reads commands interactively
104 + when run, you must cause it, when started running for such
105 + interactive use in the most ordinary way, to print or display an
106 + announcement including an appropriate copyright notice and a
107 + notice that there is no warranty (or else, saying that you provide
108 + a warranty) and that users may redistribute the program under
109 + these conditions, and telling the user how to view a copy of this
110 + License. (Exception: if the Program itself is interactive but
111 + does not normally print such an announcement, your work based on
112 + the Program is not required to print an announcement.)
113 +
114 +These requirements apply to the modified work as a whole. If
115 +identifiable sections of that work are not derived from the Program,
116 +and can be reasonably considered independent and separate works in
117 +themselves, then this License, and its terms, do not apply to those
118 +sections when you distribute them as separate works. But when you
119 +distribute the same sections as part of a whole which is a work based
120 +on the Program, the distribution of the whole must be on the terms of
121 +this License, whose permissions for other licensees extend to the
122 +entire whole, and thus to each and every part regardless of who wrote it.
123 +
124 +Thus, it is not the intent of this section to claim rights or contest
125 +your rights to work written entirely by you; rather, the intent is to
126 +exercise the right to control the distribution of derivative or
127 +collective works based on the Program.
128 +
129 +In addition, mere aggregation of another work not based on the Program
130 +with the Program (or with a work based on the Program) on a volume of
131 +a storage or distribution medium does not bring the other work under
132 +the scope of this License.
133 +
134 + 3. You may copy and distribute the Program (or a work based on it,
135 +under Section 2) in object code or executable form under the terms of
136 +Sections 1 and 2 above provided that you also do one of the following:
137 +
138 + a) Accompany it with the complete corresponding machine-readable
139 + source code, which must be distributed under the terms of Sections
140 + 1 and 2 above on a medium customarily used for software interchange; or,
141 +
142 + b) Accompany it with a written offer, valid for at least three
143 + years, to give any third party, for a charge no more than your
144 + cost of physically performing source distribution, a complete
145 + machine-readable copy of the corresponding source code, to be
146 + distributed under the terms of Sections 1 and 2 above on a medium
147 + customarily used for software interchange; or,
148 +
149 + c) Accompany it with the information you received as to the offer
150 + to distribute corresponding source code. (This alternative is
151 + allowed only for noncommercial distribution and only if you
152 + received the program in object code or executable form with such
153 + an offer, in accord with Subsection b above.)
154 +
155 +The source code for a work means the preferred form of the work for
156 +making modifications to it. For an executable work, complete source
157 +code means all the source code for all modules it contains, plus any
158 +associated interface definition files, plus the scripts used to
159 +control compilation and installation of the executable. However, as a
160 +special exception, the source code distributed need not include
161 +anything that is normally distributed (in either source or binary
162 +form) with the major components (compiler, kernel, and so on) of the
163 +operating system on which the executable runs, unless that component
164 +itself accompanies the executable.
165 +
166 +If distribution of executable or object code is made by offering
167 +access to copy from a designated place, then offering equivalent
168 +access to copy the source code from the same place counts as
169 +distribution of the source code, even though third parties are not
170 +compelled to copy the source along with the object code.
171 +
172 + 4. You may not copy, modify, sublicense, or distribute the Program
173 +except as expressly provided under this License. Any attempt
174 +otherwise to copy, modify, sublicense or distribute the Program is
175 +void, and will automatically terminate your rights under this License.
176 +However, parties who have received copies, or rights, from you under
177 +this License will not have their licenses terminated so long as such
178 +parties remain in full compliance.
179 +
180 + 5. You are not required to accept this License, since you have not
181 +signed it. However, nothing else grants you permission to modify or
182 +distribute the Program or its derivative works. These actions are
183 +prohibited by law if you do not accept this License. Therefore, by
184 +modifying or distributing the Program (or any work based on the
185 +Program), you indicate your acceptance of this License to do so, and
186 +all its terms and conditions for copying, distributing or modifying
187 +the Program or works based on it.
188 +
189 + 6. Each time you redistribute the Program (or any work based on the
190 +Program), the recipient automatically receives a license from the
191 +original licensor to copy, distribute or modify the Program subject to
192 +these terms and conditions. You may not impose any further
193 +restrictions on the recipients' exercise of the rights granted herein.
194 +You are not responsible for enforcing compliance by third parties to
195 +this License.
196 +
197 + 7. If, as a consequence of a court judgment or allegation of patent
198 +infringement or for any other reason (not limited to patent issues),
199 +conditions are imposed on you (whether by court order, agreement or
200 +otherwise) that contradict the conditions of this License, they do not
201 +excuse you from the conditions of this License. If you cannot
202 +distribute so as to satisfy simultaneously your obligations under this
203 +License and any other pertinent obligations, then as a consequence you
204 +may not distribute the Program at all. For example, if a patent
205 +license would not permit royalty-free redistribution of the Program by
206 +all those who receive copies directly or indirectly through you, then
207 +the only way you could satisfy both it and this License would be to
208 +refrain entirely from distribution of the Program.
209 +
210 +If any portion of this section is held invalid or unenforceable under
211 +any particular circumstance, the balance of the section is intended to
212 +apply and the section as a whole is intended to apply in other
213 +circumstances.
214 +
215 +It is not the purpose of this section to induce you to infringe any
216 +patents or other property right claims or to contest validity of any
217 +such claims; this section has the sole purpose of protecting the
218 +integrity of the free software distribution system, which is
219 +implemented by public license practices. Many people have made
220 +generous contributions to the wide range of software distributed
221 +through that system in reliance on consistent application of that
222 +system; it is up to the author/donor to decide if he or she is willing
223 +to distribute software through any other system and a licensee cannot
224 +impose that choice.
225 +
226 +This section is intended to make thoroughly clear what is believed to
227 +be a consequence of the rest of this License.
228 +
229 + 8. If the distribution and/or use of the Program is restricted in
230 +certain countries either by patents or by copyrighted interfaces, the
231 +original copyright holder who places the Program under this License
232 +may add an explicit geographical distribution limitation excluding
233 +those countries, so that distribution is permitted only in or among
234 +countries not thus excluded. In such case, this License incorporates
235 +the limitation as if written in the body of this License.
236 +
237 + 9. The Free Software Foundation may publish revised and/or new versions
238 +of the General Public License from time to time. Such new versions will
239 +be similar in spirit to the present version, but may differ in detail to
240 +address new problems or concerns.
241 +
242 +Each version is given a distinguishing version number. If the Program
243 +specifies a version number of this License which applies to it and "any
244 +later version", you have the option of following the terms and conditions
245 +either of that version or of any later version published by the Free
246 +Software Foundation. If the Program does not specify a version number of
247 +this License, you may choose any version ever published by the Free Software
248 +Foundation.
249 +
250 + 10. If you wish to incorporate parts of the Program into other free
251 +programs whose distribution conditions are different, write to the author
252 +to ask for permission. For software which is copyrighted by the Free
253 +Software Foundation, write to the Free Software Foundation; we sometimes
254 +make exceptions for this. Our decision will be guided by the two goals
255 +of preserving the free status of all derivatives of our free software and
256 +of promoting the sharing and reuse of software generally.
257 +
258 + NO WARRANTY
259 +
260 + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 +REPAIR OR CORRECTION.
269 +
270 + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 +POSSIBILITY OF SUCH DAMAGES.
279 +
280 + END OF TERMS AND CONDITIONS
281 +
282 + How to Apply These Terms to Your New Programs
283 +
284 + If you develop a new program, and you want it to be of the greatest
285 +possible use to the public, the best way to achieve this is to make it
286 +free software which everyone can redistribute and change under these terms.
287 +
288 + To do so, attach the following notices to the program. It is safest
289 +to attach them to the start of each source file to most effectively
290 +convey the exclusion of warranty; and each file should have at least
291 +the "copyright" line and a pointer to where the full notice is found.
292 +
293 + <one line to give the program's name and a brief idea of what it does.>
294 + Copyright (C) <year> <name of author>
295 +
296 + This program is free software; you can redistribute it and/or modify
297 + it under the terms of the GNU General Public License as published by
298 + the Free Software Foundation; either version 2 of the License, or
299 + (at your option) any later version.
300 +
301 + This program is distributed in the hope that it will be useful,
302 + but WITHOUT ANY WARRANTY; without even the implied warranty of
303 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 + GNU General Public License for more details.
305 +
306 + You should have received a copy of the GNU General Public License
307 + along with this program; if not, write to the Free Software
308 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
309 +
310 +
311 +Also add information on how to contact you by electronic and paper mail.
312 +
313 +If the program is interactive, make it output a short notice like this
314 +when it starts in an interactive mode:
315 +
316 + Gnomovision version 69, Copyright (C) year name of author
317 + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318 + This is free software, and you are welcome to redistribute it
319 + under certain conditions; type `show c' for details.
320 +
321 +The hypothetical commands `show w' and `show c' should show the appropriate
322 +parts of the General Public License. Of course, the commands you use may
323 +be called something other than `show w' and `show c'; they could even be
324 +mouse-clicks or menu items--whatever suits your program.
325 +
326 +You should also get your employer (if you work as a programmer) or your
327 +school, if any, to sign a "copyright disclaimer" for the program, if
328 +necessary. Here is a sample; alter the names:
329 +
330 + Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331 + `Gnomovision' (which makes passes at compilers) written by James Hacker.
332 +
333 + <signature of Ty Coon>, 1 April 1989
334 + Ty Coon, President of Vice
335 +
336 +This General Public License does not permit incorporating your program into
337 +proprietary programs. If your program is a subroutine library, you may
338 +consider it more useful to permit linking proprietary applications with the
339 +library. If this is what you want to do, use the GNU Library General
340 +Public License instead of this License.
ChangeLogView
@@ -1,0 +1,2 @@
1 +Version 0.1, July 16, 2000
2 + First semi-distributed version
NewsView
@@ -1,0 +1,1 @@
1 +No news is good news.
READMEView
@@ -1,0 +1,68 @@
1 +FreeCheck v0.1 July 16, 2000
2 +Eric Sandeen, <eric_sandeen@bigfoot.com>
3 +
4 +WHY?
5 +---
6 +MIPS/VersaCheck ticked me off with their (IMHO) shoddy check-printing
7 +application, and their dismal customer service. So here you go.
8 +
9 +REQUIREMENTS
10 +------------
11 +The first thing that you MUST have to be able to use FreeCheck is a
12 +good Type 1 MICR font. I have created one, called "GnuMICR" that I think
13 +is pretty excellent - but it has not been tested. :) There are also
14 +commercial fonts you can buy, if that floats your boat. See
15 +www.bizfonts.com, for example.
16 +
17 +You must also have either a PostScript printer, or a recent version
18 +of GhostScript. FreeCheck generates the check as a PostScript file.
19 +
20 +CONFIGURATION
21 +-------------
22 +Edit the file freecheck.cfg to add your account information, and define
23 +any new check blanks or styles you want. Take a look at the [Global]
24 +section, too, to set things up for your system.
25 +
26 +USAGE
27 +-----
28 +FreeCheck just prints a PostScript file to STDOUT. That means that you
29 +must either redirect it to a file, a printer, or a viewer (ggv accepts
30 +a file on STDIN - I don't think gv does).
31 +
32 +So, to print (assuming a PostScript printer, or GhostView filter):
33 +freecheck.pl <options> | lpr
34 +
35 +To view:
36 +freecheck.pl <options> | ggv
37 +
38 +To save a file:
39 +freecheck.pl <options> > mycheckfile.ps
40 +
41 +OPTIONS
42 +-------
43 +freecheck doesn't require any options, unless you want it to do something
44 +useful. By itself, it will print a couple sheets of standard checks
45 +with a dummy account.
46 +
47 +Type "freecheck --help" to see what options are available
48 +
49 +For now, if you get tired of typing all those command line options, just
50 +edit the defaults at the top of the main script.
51 +
52 +HOW DOES IT WORK?
53 +-----------------
54 +FreeCheck is a Frankenstein-like combination of PostScript and Perl,
55 +at this point. The guts of the check layout are in PostScript, which
56 +is embedded at the end of the Perl script. This PostScript depends on
57 +lots of variable definitions to decide what it should actually print.
58 +That's where the Perl comes in - reading a config file, and generating
59 +lots of lines of the type
60 + /foo {bar} def
61 +which define what's shown on the page.
62 +
63 +The file "example_check.ps" is a fairly well commented example of the
64 +PostScript that is output by freecheck. If you want to add something
65 +to the layout, it may be easier to work with that file, get it going,
66 +and then add the changes to the perl script. And send them to me,
67 +of course! :-)
68 +
TODOView
@@ -1,0 +1,20 @@
1 +Things to do, in no particular order:
2 +
3 + * Implement some sort of bank logo inclusion (.eps file)
4 + * Fix all the regexp problems that are surely in there
5 + * Allow for a global config file, and a personal config file
6 + * Write a CGI version, or include it in the same file
7 + * Allow some defaults to be set in the config file to shorten command line
8 + * Tweak PostScript to make sure nothing falls in the "forbidden" MICR area
9 + * Print receipts or whatever on check blanks that allow space for that
10 + * Command-line options for payee, date, memo, and amount
11 + (Print out entire, filled out check, not just empty)
12 + * Write a GUI around this thing
13 + * Get more check blank definitions
14 + * Pass MICR tweaks on command line (?)
15 + * Include a --print option on command line?
16 + * Include a --pdf option on command line? (generate PDF, not PS)
17 + * Add Document Structuring Convention stuff to the PS file
18 +
19 +And finally...
20 + * Get brave enough to see if one of these puppies actually clears the bank!
example_check.psView
@@ -1,0 +1,524 @@
1 +%!
2 +%---------------
3 +%
4 +% FreeCheck - a free check printing application released
5 +% under the GNU General Public Licene.
6 +%
7 +% Copyright (C) 2000 Eric Sandeen (eric_sandeen@bigfoot.com)
8 +%
9 +% This program is free software; you can redistribute it and/or modify
10 +% it under the terms of the GNU General Public License as published by
11 +% the Free Software Foundation; either version 2 of the License, or
12 +% (at your option) any later version.
13 +%
14 +% This program is distributed in the hope that it will be useful,
15 +% but WITHOUT ANY WARRANTY; without even the implied warranty of
16 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 +% GNU General Public License for more details.
18 +%
19 +% You should have received a copy of the GNU General Public License
20 +% along with this program; if not, write to the Free Software
21 +% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 +%
23 +%---------------
24 +
25 +% Let's get this out of the way first:
26 +/inch {72 mul} def
27 +
28 +%%%%%%%%%%%%%%%%%%%%%
29 +% Account info %
30 +% Text on the check %
31 +% (The Account File)%
32 +%%%%%%%%%%%%%%%%%%%%%
33 +
34 +
35 +% Things to define at each printing
36 +% ---------------------------------
37 +% ---------------------------------
38 +
39 +% Check number
40 +% ------------
41 +% Check number for first check on the page
42 +
43 +/CheckNumber 100 def
44 +
45 +% Parts to print
46 +% --------------
47 +% What exactly do we want to print? This is so that people can use
48 +% special MICR toner if they want, and print two-pass
49 +
50 +/PrintCheckBody true def
51 +/PrintMICRLine true def
52 +
53 +% Number of pages to print
54 +/NumPages 3 def
55 +
56 +% Prints a big VOID over the check
57 +/PrintVOID false def
58 +
59 +% Basic account information
60 +% -------------------------
61 +% -------------------------
62 +
63 +% Account Holder's Name, etc
64 +% --------------------------
65 +% If Name2 or Address2 are empty, they will not be printed
66 +
67 +/Name1 (JOHN SMITH) def
68 +/Name2 (MARY SMITH) def
69 +/Address1 (1234 Main Street) def
70 +/Address2 () def
71 +/CityStateZip (Anytown, USA 12345) def
72 +/PhoneNumber (512-555-1212) def
73 +
74 +% Bank information
75 +% ----------------
76 +% If BankAddr2 is empty, it will not be printed
77 +
78 +/BankName (GlobalMegaCorp, NA) def
79 +/BankAddr1 (123 Main Street) def
80 +/BankAddr2 (PO Box 45) def
81 +/BankCityStateZip (Anytown, USA 12345) def
82 +
83 +% Account Information
84 +% -------------------
85 +
86 +/RoutingNumber (012345678) def % Leftmost MICR numbers
87 +/AccountNumber (1234567890) def % Middle MICR numbers
88 +/Fraction (12345/67890) def % Fraction at top of check
89 +
90 +% MICR Line placement "Tweaking"
91 +%-------------------------------
92 +% We add the MICR tweaking here (rather than in the check
93 +% blank definition) because it's likely the user will
94 +% need to change this. The blank definition may not be
95 +% writeable by the user
96 +
97 +/MICRVerTweak {0} def
98 +/MICRHorTweak {0} def
99 +
100 +%%%%%%%%%%%%%%%%%%%%%%%%%
101 +% Check Style %
102 +% Fonts and Layout Info %
103 +% (The Style File) %
104 +%%%%%%%%%%%%%%%%%%%%%%%%%
105 +
106 +% Font Names & Sizes
107 +% ------------------
108 +% The StandardFontSize is just the basic size for non-MICR
109 +% text. Things get scaled a bit from there (Names are larger than
110 +% addresses, etc)
111 +
112 +/StandardFontName /AvantGarde-Book def
113 +/StandardFontSize 9 def
114 +
115 +% This is NOT THE MICR FONT! It is the check number on top right
116 +/CheckNumFont /Helvetica-Bold def
117 +/CheckNumSize 14 def
118 +
119 +% Margins, etc, within the check itself
120 +% -------------------------------------
121 +
122 +/LeftMargin {0.2 inch} def
123 +/RightMargin {0.4 inch} def
124 +/TopMargin {0.2 inch} def
125 +
126 +% Check feature placement
127 +% -----------------------
128 +% (relative to bottom left corner of check)
129 +
130 +/MemoLineHeight {0.25 CheckHeight mul} def
131 +/SignatureLineHeight {0.25 CheckHeight mul} def
132 +/AmountLineHeight {0.50 CheckHeight mul} def
133 +/PayeeLineHeight {0.60 CheckHeight mul} def
134 +/BankInfoHeight {0.45 CheckHeight mul} def
135 +/DateLineHeight {0.75 CheckHeight mul} def
136 +
137 +%%%%%%%%%%%%%%%%%%%%%%%%%%
138 +% Check Blank Dimensions %
139 +% (The Check Blank File) %
140 +%%%%%%%%%%%%%%%%%%%%%%%%%%
141 +
142 +% Information about how the checks are laid out on the page
143 +% ---------------------------------------------------------
144 +
145 +/CheckHeight {2.85 inch} def
146 +/CheckWidth {5.96 inch} def
147 +/CheckHorOffset {2.54 inch} def % how far are checks from left edge of sheet
148 +/CheckVerOffset {2.48 inch} def % how far is bottom check from bottom of sheet
149 +/ChecksPerPage {3} def % How many checks are on the sheet? (vertical)
150 +
151 +%%%%%%%%%%%%%%%%%%%%%%%
152 +% Global Setup Values %
153 +%%%%%%%%%%%%%%%%%%%%%%%
154 +
155 +% MICR Font
156 +% ---------
157 +% For the MICR font, SIZE MATTERS! Make sure you have the right point
158 +% size for the particular MICR font you're using. Most (including
159 +% GnuMICR) are correct at 12 pts, but READ THE DOCS THAT CAME WITH
160 +% THE FONT! :)
161 +
162 +/MICRFontName /GnuMICR def
163 +/MICRFontSize 12 def
164 +
165 +% MICR Symbol Mapping
166 +% -------------------
167 +% Maps which characters show which MICR symbols in the font you're using
168 +% Approximate representations of these symbols, with names, below:
169 +% |: = TransitNumberSymbol
170 +% / = Amount
171 +% P = OnUs
172 +% - = Dash
173 +
174 +/TransitSymbol (A) def
175 +/OnUsSymbol (C) def
176 +/AmountSymbol (B) def
177 +/DashSymbol (D) def
178 +
179 +% MICR Line placement
180 +% -------------------
181 +% This should be smack in the middle of the tolerance band...
182 +% Tweaks are accomplished by the user in the Global section
183 +
184 +/MICRLineHeight {0.25 inch} def
185 +
186 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
187 +% End of user entered information %
188 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
189 +
190 +% Other Constants:
191 +
192 +% Size of the rectangular box for the amount (digits)
193 +/AmountBoxWidth {1 inch} def
194 +/AmountBoxHeight {0.25 inch} def
195 +
196 +/LineWidth {0.3} def
197 +
198 +% Max number of digits in check number, and allocate string
199 +/CheckNumDigits 4 def
200 +/CheckNumberString CheckNumDigits string def
201 +
202 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
203 +% Helpful Printing Routines %
204 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
205 +
206 +% Shows a line, then does a "carriage return / line feed"
207 +% But only if the string exists (more than 0 chars)
208 +% (How do we get the current font size (height)?)
209 +
210 +/ShowAndCR {
211 + % A couple copies of the string (now 3 on stack)
212 + dup dup
213 + length 0 gt { % First copy
214 + show % Second copy
215 + stringwidth pop neg 0 rmoveto % Third copy & move back
216 + neg 0 exch rmoveto % line down
217 + } if
218 +} def
219 +
220 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
221 +% Feature Printing Routines %
222 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
223 +
224 +/DrawMemoLine {
225 + LeftMargin MemoLineHeight moveto
226 + 2.5 inch 0 inch rlineto
227 + -2.5 inch 0 inch rmoveto
228 + 0 2 rmoveto
229 + (for) show
230 +} def
231 +
232 +/DrawSignatureLine { % Expects height of signature line
233 + % and right edge of check for
234 + % beginning position
235 +
236 + CheckWidth SignatureLineHeight moveto
237 + RightMargin neg 0 rmoveto
238 + -2.5 inch 0 rmoveto
239 + 2.5 inch 0 inch rlineto
240 +
241 +} def
242 +
243 +/DrawAmountLine {
244 + CheckWidth AmountLineHeight moveto
245 + RightMargin neg 0 rmoveto
246 + (DOLLARS) stringwidth pop neg 0 rmoveto
247 + (DOLLARS) show
248 + (DOLLARS) stringwidth pop neg 0 rmoveto
249 + -2 0 rmoveto
250 + LeftMargin AmountLineHeight lineto
251 +} def
252 +
253 +/DrawAccountHolderInfo {
254 + LeftMargin CheckHeight moveto
255 + 0 TopMargin neg rmoveto
256 + 0 StandardFontSize neg rmoveto
257 +
258 +
259 + StandardFontSize Name1 ShowAndCR
260 + %Name1 show
261 + %Name1 stringwidth pop neg StandardFontSize neg rmoveto
262 +
263 +
264 + StandardFontSize Name2 ShowAndCR
265 + % Show Name2 only if present
266 + %Name2 length 0 gt {
267 + % Name2 show
268 + % Name2 stringwidth pop neg StandardFontSize neg rmoveto
269 + %} if
270 +
271 + StandardFontName findfont
272 + StandardFontSize 1 sub scalefont
273 + setfont
274 +
275 + StandardFontSize 1 sub Address1 ShowAndCR
276 + %Address1 stringwidth pop neg StandardFontSize neg rmoveto
277 +
278 + % Show Address2 only if present
279 + Address2 length 0 gt {
280 + Address2 show
281 + Address2 stringwidth pop neg StandardFontSize neg rmoveto
282 + } if
283 +
284 + CityStateZip show
285 + CityStateZip stringwidth pop neg StandardFontSize neg rmoveto
286 +
287 + % Show PhoneNumber only if present
288 + PhoneNumber length 0 gt {
289 + PhoneNumber show
290 + PhoneNumber stringwidth pop neg StandardFontSize neg rmoveto
291 + } if
292 +
293 + StandardFontName findfont
294 + StandardFontSize 1 add scalefont
295 + setfont
296 +} def
297 +
298 +/DrawDateLine {
299 + 0.6 CheckWidth mul DateLineHeight moveto
300 + (Date) show
301 + 1 inch 0 rlineto
302 +} def
303 +
304 +/DrawBankInfo {
305 + LeftMargin BankInfoHeight moveto
306 +
307 + BankName show
308 + BankName stringwidth pop neg StandardFontSize neg rmoveto
309 +
310 + StandardFontName findfont
311 + StandardFontSize 1 sub scalefont
312 + setfont
313 +
314 + BankAddr1 show
315 + BankAddr1 stringwidth pop neg StandardFontSize neg rmoveto
316 +
317 + % Show Addr2 only if present
318 + BankAddr2 length 0 gt {
319 + BankAddr2 show
320 + BankAddr2 stringwidth pop neg StandardFontSize neg rmoveto
321 + } if
322 +
323 + BankCityStateZip show
324 + BankCityStateZip stringwidth pop neg StandardFontSize neg rmoveto
325 +
326 + StandardFontName findfont
327 + StandardFontSize 1 add scalefont
328 + setfont
329 +} def
330 +
331 +/DrawPayeeLine {
332 +
333 + LeftMargin PayeeLineHeight moveto
334 + (ORDER OF) show
335 + (ORDER OF) stringwidth pop neg StandardFontSize rmoveto
336 + (PAY TO THE) show
337 + 0 StandardFontSize neg rmoveto
338 + 4 0 rmoveto
339 + currentpoint mark
340 +
341 + CheckWidth PayeeLineHeight moveto
342 + RightMargin neg 0 rmoveto
343 + AmountBoxWidth neg 0 rmoveto
344 +
345 + 0 AmountBoxHeight rlineto
346 + AmountBoxWidth 0 rlineto
347 + 0 AmountBoxHeight neg rlineto
348 + AmountBoxWidth neg 0 rlineto
349 +
350 + -4 0 rmoveto
351 +
352 + /Helvetica-Bold findfont
353 + 14 scalefont
354 + setfont
355 +
356 + ($) stringwidth pop neg 0 rmoveto
357 + ($) show
358 + ($) stringwidth pop neg 0 rmoveto
359 +
360 + -4 0 rmoveto
361 + cleartomark
362 + lineto
363 +
364 + StandardFontName findfont
365 + StandardFontSize scalefont
366 + setfont
367 +
368 +} def
369 +
370 +/DrawMICR {
371 + % 0.25 high, 5.6875 from right edge should be in the middle
372 + % of the tolerance band
373 + CheckWidth 0.25 inch moveto
374 + -5.6875 inch 0 inch rmoveto
375 + MICRHorTweak MICRVerTweak rmoveto
376 +
377 + save
378 + MICRFontName findfont
379 + MICRFontSize scalefont
380 + setfont
381 + TransitSymbol show
382 + RoutingNumber show
383 + TransitSymbol show
384 + ( ) show
385 + % Pad with spaces if acct number is short
386 + 12 AccountNumber length sub {( ) show} repeat
387 + AccountNumber show
388 + OnUsSymbol show
389 + ( ) show
390 + % Same deal, pad w/ 0s if short check number
391 + CheckNumDigits 1 sub -1 1
392 + {CheckNumberString exch get 0 eq {(0) show} if } for
393 + CheckNumberString show
394 + restore
395 +} def
396 +
397 +/DrawCheckNumber {
398 + CheckWidth CheckHeight moveto
399 + RightMargin neg TopMargin neg rmoveto
400 + CheckNumFont findfont
401 + CheckNumSize scalefont
402 + setfont
403 +
404 + CheckNumberString stringwidth pop neg 0 rmoveto
405 + 0 -14 rmoveto
406 + CheckNumberString show
407 +
408 + StandardFontName findfont
409 + StandardFontSize scalefont
410 + setfont
411 +} def
412 +
413 +/DrawFraction {
414 + 0.6 CheckWidth mul CheckHeight moveto
415 + 0 TopMargin neg rmoveto
416 + 0 StandardFontSize neg rmoveto
417 + Fraction show
418 +} def
419 +
420 +/DrawStub {
421 + CheckHorOffset 2 inch ge {
422 + save
423 + newpath
424 + CheckHorOffset neg 0 translate
425 + StandardFontName findfont
426 + StandardFontSize 1 sub scalefont
427 + setfont
428 + /StubSpacing {CheckHeight 6 div} def
429 + CheckHorOffset 2 div StubSpacing 5 mul moveto
430 + CheckNumberString show
431 + 0.3 inch StubSpacing 4 mul moveto
432 + (Date ) show
433 + CheckHorOffset 0.3 inch sub StubSpacing 4 mul lineto
434 + 0.3 inch StubSpacing 3 mul moveto
435 + (Payee ) show
436 + CheckHorOffset 0.3 inch sub StubSpacing 3 mul lineto
437 + 0.3 inch StubSpacing 2 mul moveto
438 + (Amount ) show
439 + CheckHorOffset 0.3 inch sub StubSpacing 2 mul lineto
440 + 0.3 inch StubSpacing 1 mul moveto
441 + (Memo ) show
442 + CheckHorOffset 0.3 inch sub StubSpacing 1 mul lineto
443 + stroke
444 + restore
445 + } if
446 +} def
447 +
448 +/DrawVOID {
449 + save
450 + StandardFontName findfont
451 + 50 scalefont
452 + setfont
453 + newpath
454 + CheckWidth 2 div 1 inch moveto
455 + 30 rotate
456 + (V O I D) stringwidth pop 0 moveto
457 + (V O I D) true charpath
458 + stroke
459 + restore
460 +} def
461 +
462 +/DrawCheck {
463 + % Temporarily draw boxes around the checks
464 + 0 0 moveto
465 + CheckWidth 0 lineto
466 + CheckWidth CheckHeight lineto
467 + 0 CheckHeight lineto
468 + 0 0 lineto
469 +
470 + % Convert CheckNumber integer to a string
471 + PrintCheckBody {
472 + CheckNumber CheckNumberString cvs
473 + DrawBankInfo
474 + DrawAccountHolderInfo
475 + DrawMemoLine
476 + DrawSignatureLine
477 + DrawAmountLine
478 + DrawPayeeLine
479 + DrawCheckNumber
480 + DrawFraction
481 + DrawDateLine
482 + } if
483 +
484 + PrintMICRLine {
485 + DrawMICR
486 + } if
487 +
488 + PrintVOID {
489 + DrawVOID
490 + } if
491 +
492 +} def
493 +
494 +
495 +/CurrentPage 1 def
496 +
497 +NumPages -1 1 {
498 + /CheckNumber CheckNumber ChecksPerPage add def
499 + CheckHorOffset CheckVerOffset translate
500 +
501 + StandardFontName findfont
502 + StandardFontSize scalefont
503 + setfont
504 +
505 + LineWidth setlinewidth
506 +
507 + % Loop through printing checks, starting with the bottom one
508 +
509 + ChecksPerPage -1 1 {
510 + /CheckNumber CheckNumber 1 sub def
511 + newpath
512 +
513 + DrawCheck
514 + DrawStub % But only if there is room
515 +
516 + stroke
517 + 0 CheckHeight translate
518 + } for
519 +
520 + showpage
521 + /CheckNumber CheckNumber ChecksPerPage add def
522 + /CurrentPage CurrentPage 1 add def
523 +
524 +} for
freecheck.cfgView
@@ -1,0 +1,246 @@
1 +# Freecheck Configuration File
2 +
3 +# Format:
4 +# Sections of the format:
5 +
6 +# [SectionType SectionName]
7 +# key1 = value1
8 +# key2 = value2
9 +
10 +# SECTION HEADERS
11 +# Section headers are formatted like this:
12 +# [SectionType Label]
13 +# Where SectionType is either "Global" "Style" "Account" or "CheckBlank"
14 +# Label is the name of this particularinition
15 +# i.e. [Style Normal] is the section that defines the normal style (!)
16 +# The "Global" section does not take a SectionType
17 +# i.e. [Global]
18 +# No part of the header is case sensitive
19 +
20 +
21 +# KEY-VALUE PAIRS
22 +# Key-value pairs are separated by an "=" with optional whitespace
23 +# i.e. "Key1 = Value1" or "Key1=Value1"
24 +# Key names ARE case-sensitive, since they become PostScriptinitions
25 +# Some values (such as font names) are case sensitive
26 +# Others, such as address strings, will print in whatever case you enter them
27 +# Values may be multiple words
28 +# Values which represent dimensions may be bare numbers (which results in
29 +# "points," or 1/72 of an inch) or followed by "inch" which should be
30 +# self-explanatory.
31 +
32 +# Each section contains comments showing all required key-value pairs, and
33 +# examples of assignments.
34 +
35 +###################
36 +# Global defaults #
37 +###################
38 +
39 +# Keys:
40 +
41 +# MICR Font
42 +# ---------
43 +# For the MICR font, SIZE MATTERS! Make sure you have the right point
44 +# size for the particular MICR font you're using. Most (including
45 +# GnuMICR) are correct at 12 pts, but READ THE DOCS THAT CAME WITH
46 +# THE FONT! :)
47 +
48 +# MICRFontName = GnuMICR
49 +# MICRFontSize = 12
50 +
51 +# MICR Symbol Mapping
52 +# -------------------
53 +# Maps which characters show which MICR symbols in the font you're using
54 +# Approximate representations of these symbols, with names, below:
55 +# |: = TransitSymbol
56 +# / = Amount
57 +# P = OnUs
58 +# - = Dash
59 +
60 +# TransitSymbol = A
61 +# OnUsSymbol = C
62 +# AmountSymbol = B
63 +# DashSymbol = D
64 +
65 +# MICR Line placement "Tweaking"
66 +#-------------------------------
67 +# Any "tweaks" necessary to align the MICR characters
68 +# May be in points or in inches
69 +# MICRVerTweak = 0
70 +# MICRHorTweak = 0
71 +
72 +[Global]
73 +MICRFontName = GnuMICR
74 +MICRFontSize = 12
75 +TransitSymbol = A
76 +OnUsSymbol = C
77 +AmountSymbol = B
78 +DashSymbol = D
79 +MICRVerTweak = 0
80 +MICRHorTweak = 0
81 +
82 +############
83 +# Accounts #
84 +############
85 +
86 +# Check number for first check on the page
87 +# CheckNumber = 441
88 +
89 +# Check Parts to print
90 +# --------------------
91 +# What exactly do we want to print? This is so that people can use
92 +# special MICR toner if they want, and print two-pass
93 +# PrintCheckBody = true
94 +# PrintMICRLine = true
95 +
96 +# Number of pages to print
97 +# NumPages = 3
98 +
99 +# Account Holder's Name, etc
100 +# --------------------------
101 +# If any strings are empty, they will not be printed
102 +
103 +# Name1 = JOHN SMITH
104 +# Name2 = MARY SMITH
105 +# Address1 = 1234 Main Street
106 +# Address2 =
107 +# CityStateZip = Anytown, USA 12345
108 +# PhoneNumber = 512-555-1212
109 +
110 +# Bank information
111 +# ----------------
112 +# If any strings are empty, they will not be printed
113 +# BankName = MegaCorp Bank, NA
114 +# BankAddr1 = 6780 Main Street
115 +# BankAddr2 = Suite 45
116 +# BankCityStateZip = Anytown, USA 12345
117 +
118 +# Account Information
119 +# -------------------
120 +
121 +# RoutingNumber = 012345678 # Leftmost MICR numbers
122 +# AccountNumber = 1234567890 # Middle MICR numbers
123 +# Fraction = 12345/67890 # Fraction at top of check
124 +
125 +[Account Sample]
126 +PrintCheckBody = true
127 +CheckNumber = 100
128 +PrintMICRLine = true
129 +NumPages = 2
130 +Name1 = JOHN SMITH
131 +Name2 = MARY SMITH
132 +Address1 = 1234 Main Street
133 +Address2 =
134 +CityStateZip = Anytown, USA 12345
135 +PhoneNumber = 512-555-1212
136 +BankName = MegaCorp Bank, NA
137 +BankAddr1 = 6780 Main Street
138 +BankAddr2 = Suite 45
139 +BankCityStateZip = Anytown, USA 12345
140 +RoutingNumber = 012345678
141 +AccountNumber = 1234567890
142 +Fraction = 12345/67890
143 +
144 +################
145 +# Check Styles #
146 +################
147 +
148 +# Font Names & Sizes
149 +# ------------------
150 +# The StandardFontSize is just the basic size for non-MICR
151 +# text. Things get scaled a bit from there (Names are larger than
152 +# addresses, etc)
153 +# StandardFontName = AvantGarde-Book
154 +# StandardFontSize = 9
155 +
156 +# This is NOT THE MICR FONT! It is the big check number on top right
157 +# CheckNumFont = Helvetica-Bold
158 +# CheckNumSize = 14
159 +
160 +# Check feature placement
161 +# -----------------------
162 +# (relative to bottom of check)
163 +# Currently implemented as multiples of the check height
164 +# Could be absolute (inches) but would break across different
165 +# types of check blanks
166 +# MemoLineHeight = 0.25 CheckHeight mul
167 +# SignatureLineHeight = 0.25 CheckHeight mul
168 +# BankInfoHeight = 0.45 CheckHeight mul
169 +# AmountLineHeight = 0.50 CheckHeight mul
170 +# PayeeLineHeight = 0.60 CheckHeight mul
171 +# DateLineHeight = 0.75 CheckHeight mul
172 +
173 +[Style Normal]
174 +StandardFontName = AvantGarde-Book
175 +StandardFontSize = 9
176 +CheckNumFont = Helvetica-Bold
177 +CheckNumSize = 14
178 +MemoLineHeight = 0.25 CheckHeight mul
179 +SignatureLineHeight = 0.25 CheckHeight mul
180 +BankInfoHeight = 0.45 CheckHeight mul
181 +AmountLineHeight = 0.50 CheckHeight mul
182 +PayeeLineHeight = 0.60 CheckHeight mul
183 +DateLineHeight = 0.75 CheckHeight mul
184 +
185 +################
186 +# CHECK BLANKS #
187 +################
188 +
189 +# Keys:
190 +
191 +# Information about how the checks are laid out on the page
192 +# ---------------------------------------------------------
193 +
194 +# Actual width and height of the checks, in points or inches
195 +# CheckHeight = 3.50 inch
196 +# CheckWidth = 8.50 inch
197 +
198 +# Offsets for bottom-most check, from lower left corner of page
199 +# In points or inches
200 +# CheckHorOffset = 0.00 inch
201 +# CheckVerOffset = 4.00 inch
202 +
203 +# Number of checks on each page
204 +# ChecksPerPage = 1
205 +
206 +# Information about where to print on each check
207 +# ----------------------------------------------
208 +
209 +# Margins within each check - to avoid any graphics on the check blanks
210 +# (Bottom margin fixed by MICR spec)
211 +# LeftMargin = 0.40 inch
212 +# RightMargin = 0.40 inch
213 +# TopMargin = 0.25 inch
214 +
215 +[CheckBlank MVD1001]
216 +# MIP/SDLA VersaCheck MVD1001 "Business" checks
217 +CheckHeight = 3.50 inch
218 +CheckWidth = 8.50 inch
219 +CheckHorOffset = 0.00 inch
220 +CheckVerOffset = 4.00 inch
221 +ChecksPerPage = 1
222 +LeftMargin = 0.40 inch
223 +RightMargin = 0.40 inch
224 +TopMargin = 0.25 inch
225 +
226 +[CheckBlank MVG1000]
227 +# MIPS/DLA VersaCheck MVG1000 "Business" checks
228 +CheckHeight = 3.50 inch
229 +CheckWidth = 8.50 inch
230 +CheckHorOffset = 0.00 inch
231 +CheckVerOffset = 7.50 inch
232 +ChecksPerPage = 1
233 +LeftMargin = 0.30 inch
234 +RightMargin = 0.30 inch
235 +TopMargin = 0.25 inch
236 +
237 +[CheckBlank MVG3001]
238 +# MIPS/DLA VersaCheck MVG3001 "Personal" checks
239 +CheckHeight = 2.83 inch
240 +CheckWidth = 6.00 inch
241 +CheckHorOffset = 2.50 inch
242 +CheckVerOffset = 2.50 inch
243 +ChecksPerPage = 3
244 +LeftMargin = 0.20 inch
245 +RightMargin = 0.25 inch
246 +TopMargin = 0.20 inch
freecheck.plView
@@ -1,0 +1,640 @@
1 +#!/usr/bin/perl
2 +
3 +#---------------
4 +#
5 +# FreeCheck - a free check printing application released
6 +# under the GNU General Public Licene.
7 +#
8 +# Copyright (C) 2000 Eric Sandeen (eric_sandeen@bigfoot.com)
9 +#
10 +# This program is free software; you can redistribute it and/or modify
11 +# it under the terms of the GNU General Public License as published by
12 +# the Free Software Foundation; either version 2 of the License, or
13 +# (at your option) any later version.
14 +#
15 +# This program is distributed in the hope that it will be useful,
16 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
17 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 +# GNU General Public License for more details.
19 +#
20 +# You should have received a copy of the GNU General Public License
21 +# along with this program; if not, write to the Free Software
22 +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 +#
24 +#---------------
25 +
26 +$ConfigFile = "freecheck.cfg";
27 +
28 +# Some defaults...
29 +$opt_account = "sample";
30 +$opt_checktype = "MVG3001";
31 +$opt_checkstyle = "normal";
32 +
33 +use Getopt::Long;
34 +#use Carp;
35 +
36 +#use File::Slurp;
37 +
38 +# This tells us how to format the strings from the cfg file
39 +# so we can print it as a PostScript definition
40 +# The key read will replace "value" for each of these
41 +# Strings are enclosed in parentheses (String) (Foobar)
42 +# Fonts are preceded by a "/" /FontName /Arial
43 +# Digits are fine as they are Digit 123
44 +# Booleans are fine too Bool true
45 +# But to be safe, do digits and bools as subroutines:
46 +# Subroutines are in {} {subr} {3 mul}
47 +
48 +%Formats = qw(
49 + # Globals
50 + MICRFontName /value
51 + MICRFontSize {value}
52 + TransitSymbol (value)
53 + OnUsSymbol (value)
54 + AmountSymbol (value)
55 + DashSymbol (value)
56 + MICRVerTweak {value}
57 + MICRHorTweak {value}
58 + # Account
59 + CheckNumber {value}
60 + PrintCheckBody {value}
61 + PrintMICRLine {value}
62 + NumPages {value}
63 + Name1 (value)
64 + Name2 (value)
65 + Address1 (value)
66 + Address2 (value)
67 + CityStateZip (value)
68 + PhoneNumber (value)
69 + BankName (value)
70 + BankAddr1 (value)
71 + BankAddr2 (value)
72 + BankCityStateZip (value)
73 + RoutingNumber (value)
74 + AccountNumber (value)
75 + Fraction (value)
76 + PrintVOID {value}
77 + # Styles
78 + StandardFontName /value
79 + StandardFontSize {value}
80 + CheckNumFont /value
81 + CheckNumSize {value}
82 + MemoLineHeight {value}
83 + SignatureLineHeight {value}
84 + BankInfoHeight {value}
85 + AmountLineHeight {value}
86 + PayeeLineHeight {value}
87 + DateLineHeight {value}
88 + # Check Blank Types
89 + CheckHeight {value}
90 + CheckWidth {value}
91 + CheckHorOffset {value}
92 + CheckVerOffset {value}
93 + ChecksPerPage {value}
94 + LeftMargin {value}
95 + RightMargin {value}
96 + TopMargin {value}
97 + );
98 +
99 +# Parse command line options and deal with them:
100 +
101 +GetOptions ("account:s", # Account definition file
102 + "checknum:i", # Check number optional (overrides acct file)
103 + "pages:i", # Number of pages to print
104 + "checkstyle:s", # Check style (defaults to "normal_style.ps"
105 + "checktype:s", # Check blank definition
106 + "nomicr", # Prevents MICR line from printing (body only)
107 + "nobody", # Prevents body from printing (MICR line only)
108 + "test", # Don't increment check no. and print VOID
109 + "help")
110 +
111 +or Show_Usage();
112 +
113 +if ($opt_help) {
114 + Show_Usage();
115 +}
116 +
117 +# Pull the config file into a string...
118 +$config_file = read_file($ConfigFile);
119 +
120 +# Go through the config and fill up a hash with PostScript defines...
121 +Parse_Config($config_file);
122 +
123 +# Overwrite anything we got from the config file with what was on the
124 +# Command Line (if anything...)
125 +
126 +if ($opt_checknum) {
127 + $Definitions{"CheckNumber"} = $opt_checknum;
128 +}
129 +
130 +if ($opt_pages) {
131 + $Definitions{"NumPages"} = $opt_pages;
132 +}
133 +
134 +if ($opt_nomicr) {
135 + $Definitions{"PrintMICRLine"} = "false";
136 +}
137 +
138 +if ($opt_nobody) {
139 + $Definitions{"PrintCheckBody"} = "false";
140 +}
141 +
142 +# This probably isn't in the config file (although it might be...)
143 +# so cover both possibilites (true/false)
144 +if ($opt_test) {
145 + $Definitions{"PrintVOID"} = "true";
146 +} else {
147 + $Definitions{"PrintVOID"} = "false";
148 +}
149 +
150 +# Print PostScript
151 +
152 +# Initial stuff:
153 +
154 +print "%!\n";
155 +print "/inch {72 mul} def\n";
156 +
157 +# Go through $Definitions and print them out PostScript-Like
158 +Print_Defs();
159 +
160 +# Then print the main body
161 +Print_Body();
162 +
163 +# Update the config file with the new check number, if it's not just a test
164 +if (!$opt_test) {
165 + $next_check_number = $Definitions{"CheckNumber"}
166 + + ($Definitions{"NumPages"} * $Definitions{"ChecksPerPage"});
167 +
168 + $config_file = Replace_Val($config_file, "Account", $opt_account,
169 + "CheckNumber", $next_check_number);
170 + write_file ("freecheck.cfg", $config_file);
171 +}
172 +
173 +###############
174 +# Subroutines #
175 +###############
176 +
177 +# read_file and write_file shamelessly stolen from the File::Slurp module
178 +# Short enough, and I didn't want to require a non-standard module
179 +
180 +sub read_file
181 +{
182 + my ($file) = @_;
183 +
184 + local(*F);
185 + my $r;
186 + my (@r);
187 +
188 + open(F, "<$file") || die "open $file: $!";
189 + @r = <F>;
190 + close(F);
191 +
192 + return @r if wantarray;
193 + return join("",@r);
194 +}
195 +
196 +sub write_file
197 +{
198 + my ($f, @data) = @_;
199 +
200 + local(*F);
201 +
202 + open(F, ">$f") || die "open >$f: $!";
203 + (print F @data) || die "write $f: $!";
204 + close(F) || die "close $f: $!";
205 + return 1;
206 +}
207 +
208 +
209 +sub Parse_Config {
210 + local ($config_file) = ($_[0]);
211 + # Find each section we're looking for...
212 + while ($config_file =~ /^\[\s*(
213 + Global |
214 + Account\s+${opt_account} |
215 + Style\s+${opt_checkstyle} |
216 + CheckBlank\s+${opt_checktype}
217 + )\s*\]/xmgci) {
218 + # and get the lines under it one by one
219 + while ($config_file =~ /(^.+$)/mgc) {
220 + $line = $+;
221 + # If this line is a comment, skip it
222 + if ($line =~ /^#/) {
223 + next;
224 + }
225 + # If the line we just found is a new section..."[...]"
226 + if ($line =~ /\[.+\]/) {
227 + # and it is another section we're looking for
228 + # Grab the next line, and keep going
229 + if ($line =~ /\[\s*(
230 + Global |
231 + Account\s+${opt_account} |
232 + Style\s+${opt_checkstyle} |
233 + CheckBlank\s+${opt_checktype}
234 + )\s*]/xi) {
235 + # Grab the next line, and keep going
236 + next;
237 + } else {
238 + # Not a section we need, so break out
239 + # of the loop
240 + last;
241 + }
242 + }
243 +
244 + ($key, $val) = split (/\s*=\s*/,$line);
245 + $Definitions{$key} = $val;
246 + } # line-by-line while
247 + } # section match conditional
248 +}
249 +
250 +sub Replace_Val {
251 + local ($string, $section, $name, $key, $value) =
252 + ($_[0], $_[1], $_[2], $_[3], $_[4]);
253 + # We want to get "[section name] ... key = value" and replace it
254 + # with the new value.
255 +
256 + # s - "." matches ANYTHING including newline
257 + # m - ^ and $ match after and before any newline
258 + # in this case, ".+?" means the minimum number of <anything> i.e. end
259 + # when we find the first instance of $key after [section name]
260 + $string =~
261 + s/(^\[\s*$section\s+$name\s*\].+?^${key}\s*=\s*).*?$/$+$value/smi;
262 + $string;
263 +}
264 +
265 +sub Show_Usage {
266 + print "\nFreeCheck v. 0.1 - a Free Check printing Utility\n\n";
267 + print "Usage: freecheck <options>:\n";
268 + print "\n";
269 + print "options:\n";
270 + print " --account <filename> account to use (default \"$opt_account\")\n";
271 + print " --checknum <integer> starting check number (overrides cfg)\n";
272 + print " --pages <integer> number of pages to print (overrides cfg)\n";
273 + print " --checkstyle <filename> check style to use (default \"$opt_checkstyle\")\n";
274 + print " --checktype <filename> blank check type to use (default \"$opt_checktype\")\n";
275 + print " --nomicr print check body only, no MICR line\n";
276 + print " --nobody print MICR line only, no check body\n";
277 + print " --help print this message\n";
278 + print " --test print but don't increment check number\n";
279 + print " and print VOID on the check\n";
280 + print "\nconfig file \"freecheck.cfg\" must be in the same directory,\n";
281 + print "as the freecheck executable (this will change in the future...)\n";
282 + die "\n";
283 +}
284 +
285 +sub Print_Defs {
286 + # Go through each def in the hash table, and print according to the
287 + # formatting hash
288 + while ( ($key, $val) = each (%Definitions) ) {
289 + print "/$key\t";
290 + $_ = $Formats{$key};
291 + s/value/$val/;
292 + print;
293 + print " def\n";
294 + }
295 +}
296 +
297 +sub Print_Body {
298 +
299 +# This is the main body of the postscript file, that acts on all of the
300 +# definitions we got from the config file.
301 +
302 +print '
303 + % Other Constants:
304 +
305 + % Size of the rectangular box for the amount (digits)
306 + /AmountBoxWidth {1 inch} def
307 + /AmountBoxHeight {0.25 inch} def
308 +
309 + /LineWidth {0.3} def
310 +
311 + % Max number of digits in check number, and allocate string
312 + /CheckNumDigits 4 def
313 + /CheckNumberString CheckNumDigits string def
314 +
315 + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
316 + % Helpful Printing Routines %
317 + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
318 +
319 + % Shows a line, then does a "carriage return / line feed"
320 + % But only if the string exists (more than 0 chars)
321 + % (How do we get the current font size (height)?)
322 +
323 + /ShowAndCR {
324 + % A couple copies of the string (now 3 on stack)
325 + dup dup
326 + length 0 gt { % First copy
327 + show % Second copy
328 + stringwidth pop neg 0 rmoveto % Third copy & move back
329 + neg 0 exch rmoveto % line down
330 + } if
331 + } def
332 +
333 + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
334 + % Feature Printing Routines %
335 + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
336 +
337 + /DrawMemoLine {
338 + LeftMargin MemoLineHeight moveto
339 + 2.5 inch 0 inch rlineto
340 + -2.5 inch 0 inch rmoveto
341 + 0 2 rmoveto
342 + (for) show
343 + } def
344 +
345 + /DrawSignatureLine { % Expects height of signature line
346 + % and right edge of check for
347 + % beginning position
348 +
349 + CheckWidth SignatureLineHeight moveto
350 + RightMargin neg 0 rmoveto
351 + -2.5 inch 0 rmoveto
352 + 2.5 inch 0 inch rlineto
353 +
354 + } def
355 +
356 + /DrawAmountLine {
357 + CheckWidth AmountLineHeight moveto
358 + RightMargin neg 0 rmoveto
359 + (DOLLARS) stringwidth pop neg 0 rmoveto
360 + (DOLLARS) show
361 + (DOLLARS) stringwidth pop neg 0 rmoveto
362 + -2 0 rmoveto
363 + LeftMargin AmountLineHeight lineto
364 + } def
365 +
366 + /DrawAccountHolderInfo {
367 + LeftMargin CheckHeight moveto
368 + 0 TopMargin neg rmoveto
369 + 0 StandardFontSize neg rmoveto
370 +
371 +
372 + StandardFontSize Name1 ShowAndCR
373 + %Name1 show
374 + %Name1 stringwidth pop neg StandardFontSize neg rmoveto
375 +
376 +
377 + StandardFontSize Name2 ShowAndCR
378 + % Show Name2 only if present
379 + %Name2 length 0 gt {
380 + % Name2 show
381 + % Name2 stringwidth pop neg StandardFontSize neg rmoveto
382 + %} if
383 +
384 + StandardFontName findfont
385 + StandardFontSize 1 sub scalefont
386 + setfont
387 +
388 + StandardFontSize 1 sub Address1 ShowAndCR
389 + %Address1 stringwidth pop neg StandardFontSize neg rmoveto
390 +
391 + % Show Address2 only if present
392 + Address2 length 0 gt {
393 + Address2 show
394 + Address2 stringwidth pop neg StandardFontSize neg rmoveto
395 + } if
396 +
397 + CityStateZip show
398 + CityStateZip stringwidth pop neg StandardFontSize neg rmoveto
399 +
400 + % Show PhoneNumber only if present
401 + PhoneNumber length 0 gt {
402 + PhoneNumber show
403 + PhoneNumber stringwidth pop neg StandardFontSize neg rmoveto
404 + } if
405 +
406 + StandardFontName findfont
407 + StandardFontSize 1 add scalefont
408 + setfont
409 + } def
410 +
411 + /DrawDateLine {
412 + 0.6 CheckWidth mul DateLineHeight moveto
413 + (Date) show
414 + 1 inch 0 rlineto
415 + } def
416 +
417 + /DrawBankInfo {
418 + LeftMargin BankInfoHeight moveto
419 +
420 + BankName show
421 + BankName stringwidth pop neg StandardFontSize neg rmoveto
422 +
423 + StandardFontName findfont
424 + StandardFontSize 1 sub scalefont
425 + setfont
426 +
427 + BankAddr1 show
428 + BankAddr1 stringwidth pop neg StandardFontSize neg rmoveto
429 +
430 + % Show Addr2 only if present
431 + BankAddr2 length 0 gt {
432 + BankAddr2 show
433 + BankAddr2 stringwidth pop neg StandardFontSize neg rmoveto
434 + } if
435 +
436 + BankCityStateZip show
437 + BankCityStateZip stringwidth pop neg StandardFontSize neg rmoveto
438 +
439 + StandardFontName findfont
440 + StandardFontSize 1 add scalefont
441 + setfont
442 + } def
443 +
444 + /DrawPayeeLine {
445 +
446 + LeftMargin PayeeLineHeight moveto
447 + (ORDER OF) show
448 + (ORDER OF) stringwidth pop neg StandardFontSize rmoveto
449 + (PAY TO THE) show
450 + 0 StandardFontSize neg rmoveto
451 + 4 0 rmoveto
452 + currentpoint mark
453 +
454 + CheckWidth PayeeLineHeight moveto
455 + RightMargin neg 0 rmoveto
456 + AmountBoxWidth neg 0 rmoveto
457 +
458 + 0 AmountBoxHeight rlineto
459 + AmountBoxWidth 0 rlineto
460 + 0 AmountBoxHeight neg rlineto
461 + AmountBoxWidth neg 0 rlineto
462 +
463 + -4 0 rmoveto
464 +
465 + /Helvetica-Bold findfont
466 + 14 scalefont
467 + setfont
468 +
469 + ($) stringwidth pop neg 0 rmoveto
470 + ($) show
471 + ($) stringwidth pop neg 0 rmoveto
472 +
473 + -4 0 rmoveto
474 + cleartomark
475 + lineto
476 +
477 + StandardFontName findfont
478 + StandardFontSize scalefont
479 + setfont
480 +
481 + } def
482 +
483 + /DrawMICR {
484 + % 0.25 high, 5.6875 from right edge should be in the middle
485 + % of the tolerance band
486 + CheckWidth 0.25 inch moveto
487 + -5.6875 inch 0 inch rmoveto
488 + MICRHorTweak MICRVerTweak rmoveto
489 +
490 + save
491 + MICRFontName findfont
492 + MICRFontSize scalefont
493 + setfont
494 + TransitSymbol show
495 + RoutingNumber show
496 + TransitSymbol show
497 + ( ) show
498 + % Pad with spaces if acct number is short
499 + 12 AccountNumber length sub {( ) show} repeat
500 + AccountNumber show
501 + OnUsSymbol show
502 + ( ) show
503 + % Same deal, pad w/ 0s if short check number
504 + CheckNumDigits 1 sub -1 1
505 + {CheckNumberString exch get 0 eq {(0) show} if } for
506 + CheckNumberString show
507 + restore
508 + } def
509 +
510 + /DrawCheckNumber {
511 + CheckWidth CheckHeight moveto
512 + RightMargin neg TopMargin neg rmoveto
513 + CheckNumFont findfont
514 + CheckNumSize scalefont
515 + setfont
516 +
517 + CheckNumberString stringwidth pop neg 0 rmoveto
518 + 0 -14 rmoveto
519 + CheckNumberString show
520 +
521 + StandardFontName findfont
522 + StandardFontSize scalefont
523 + setfont
524 + } def
525 +
526 + /DrawFraction {
527 + 0.6 CheckWidth mul CheckHeight moveto
528 + 0 TopMargin neg rmoveto
529 + 0 StandardFontSize neg rmoveto
530 + Fraction show
531 + } def
532 +
533 + /DrawStub {
534 + CheckHorOffset 2 inch ge {
535 + save
536 + newpath
537 + CheckHorOffset neg 0 translate
538 + StandardFontName findfont
539 + StandardFontSize 1 sub scalefont
540 + setfont
541 + /StubSpacing {CheckHeight 6 div} def
542 + CheckHorOffset 2 div StubSpacing 5 mul moveto
543 + CheckNumberString show
544 + 0.3 inch StubSpacing 4 mul moveto
545 + (Date ) show
546 + CheckHorOffset 0.3 inch sub StubSpacing 4 mul lineto
547 + 0.3 inch StubSpacing 3 mul moveto
548 + (Payee ) show
549 + CheckHorOffset 0.3 inch sub StubSpacing 3 mul lineto
550 + 0.3 inch StubSpacing 2 mul moveto
551 + (Amount ) show
552 + CheckHorOffset 0.3 inch sub StubSpacing 2 mul lineto
553 + 0.3 inch StubSpacing 1 mul moveto
554 + (Memo ) show
555 + CheckHorOffset 0.3 inch sub StubSpacing 1 mul lineto
556 + stroke
557 + restore
558 + } if
559 + } def
560 +
561 + /DrawVOID {
562 + save
563 + StandardFontName findfont
564 + 50 scalefont
565 + setfont
566 + newpath
567 + CheckWidth 2 div 1 inch moveto
568 + 30 rotate
569 + (V O I D) stringwidth pop 0 moveto
570 + (V O I D) true charpath
571 + stroke
572 + restore
573 + } def
574 +
575 + /DrawCheck {
576 + % Temporarily draw boxes around the checks
577 + 0 0 moveto
578 + CheckWidth 0 lineto
579 + CheckWidth CheckHeight lineto
580 + 0 CheckHeight lineto
581 + 0 0 lineto
582 +
583 + % Convert CheckNumber integer to a string
584 + PrintCheckBody {
585 + CheckNumber CheckNumberString cvs
586 + DrawBankInfo
587 + DrawAccountHolderInfo
588 + DrawMemoLine
589 + DrawSignatureLine
590 + DrawAmountLine
591 + DrawPayeeLine
592 + DrawCheckNumber
593 + DrawFraction
594 + DrawDateLine
595 + } if
596 +
597 + PrintMICRLine {
598 + DrawMICR
599 + } if
600 +
601 + PrintVOID {
602 + DrawVOID
603 + } if
604 +
605 + } def
606 +
607 +
608 + /CurrentPage 1 def
609 +
610 + NumPages -1 1 {
611 + /CheckNumber CheckNumber ChecksPerPage add def
612 + CheckHorOffset CheckVerOffset translate
613 +
614 + StandardFontName findfont
615 + StandardFontSize scalefont
616 + setfont
617 +
618 + LineWidth setlinewidth
619 +
620 + % Loop through printing checks, starting with the bottom one
621 +
622 + ChecksPerPage -1 1 {
623 + /CheckNumber CheckNumber 1 sub def
624 + newpath
625 +
626 + DrawCheck
627 + DrawStub % But only if there is room
628 +
629 + stroke
630 + 0 CheckHeight translate
631 + } for
632 +
633 + showpage
634 + /CheckNumber CheckNumber ChecksPerPage add def
635 + /CurrentPage CurrentPage 1 add def
636 +
637 + } for
638 + ';
639 +
640 +}

Built with git-ssb-web