Skip to content

Instantly share code, notes, and snippets.

@Elektordi
Created March 7, 2018 13:42
Show Gist options
  • Save Elektordi/0ddbba37f9c0d71652a8f91fc67f01ab to your computer and use it in GitHub Desktop.
Save Elektordi/0ddbba37f9c0d71652a8f91fc67f01ab to your computer and use it in GitHub Desktop.
Print barcode on DYMO label printer
#!/bin/bash
if [ $# -eq 1 ]
then
( echo "%!PS-Adobe-2.0 EPSF-2.0
%%Creator: dytextlab, derived from fig2dev Version 3.2 Patchlevel 5-alpha7
%%BoundingBox: 0 0 5769 52
%%EndComments
newpath
0 52 moveto 0 0 lineto 5769 0 lineto 5769 52 lineto
closepath clip
newpath
23.6 1710.0 72 mul 1143.0000 div translate
1 -1 scale
/\$F2psDict 200 dict def
\$F2psDict begin
\$F2psDict /mtrx matrix put
/col0 {0.000 0.000 0.000 srgb} bind def
/col7 {1.000 1.000 1.000 srgb} bind def
end
save
/cp {closepath} bind def
/ef {eofill} bind def
/gr {grestore} bind def
/gs {gsave} bind def
/sa {save} bind def
/rs {restore} bind def
/l {lineto} bind def
/m {moveto} bind def
/rm {rmoveto} bind def
/n {newpath} bind def
/s {stroke} bind def
/sh {show} bind def
/slc {setlinecap} bind def
/slj {setlinejoin} bind def
/slw {setlinewidth} bind def
/srgb {setrgbcolor} bind def
/rot {rotate} bind def
/sc {scale} bind def
/sd {setdash} bind def
/ff {findfont} bind def
/sf {setfont} bind def
/scf {scalefont} bind def
/sw {stringwidth} bind def
/tr {translate} bind def
/tnt {dup dup currentrgbcolor
4 -2 roll dup 1 exch sub 3 -1 roll mul add
4 -2 roll dup 1 exch sub 3 -1 roll mul add
4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
bind def
/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
4 -2 roll mul srgb} bind def
/reencdict 12 dict def /ReEncode { reencdict begin
/newcodesandnames exch def /newfontname exch def /basefontname exch def
/basefontdict basefontname findfont def /newfont basefontdict maxlength dict def
basefontdict { exch dup /FID ne { dup /Encoding eq
{ exch dup length array copy newfont 3 1 roll put }
{ exch newfont 3 1 roll put } ifelse } { pop pop } ifelse } forall
newfont /FontName newfontname put newcodesandnames aload pop
128 1 255 { newfont /Encoding get exch /.notdef put } for
newcodesandnames length 2 idiv { newfont /Encoding get 3 1 roll put } repeat
newfontname newfont definefont pop end } def
/isovec [
8#055 /minus 8#200 /grave 8#201 /acute 8#202 /circumflex 8#203 /tilde
8#204 /macron 8#205 /breve 8#206 /dotaccent 8#207 /dieresis
8#210 /ring 8#211 /cedilla 8#212 /hungarumlaut 8#213 /ogonek 8#214 /caron
8#220 /dotlessi 8#230 /oe 8#231 /OE
8#240 /space 8#241 /exclamdown 8#242 /cent 8#243 /sterling
8#244 /currency 8#245 /yen 8#246 /brokenbar 8#247 /section 8#250 /dieresis
8#251 /copyright 8#252 /ordfeminine 8#253 /guillemotleft 8#254 /logicalnot
8#255 /hyphen 8#256 /registered 8#257 /macron 8#260 /degree 8#261 /plusminus
8#262 /twosuperior 8#263 /threesuperior 8#264 /acute 8#265 /mu 8#266 /paragraph
8#267 /periodcentered 8#270 /cedilla 8#271 /onesuperior 8#272 /ordmasculine
8#273 /guillemotright 8#274 /onequarter 8#275 /onehalf
8#276 /threequarters 8#277 /questiondown 8#300 /Agrave 8#301 /Aacute
8#302 /Acircumflex 8#303 /Atilde 8#304 /Adieresis 8#305 /Aring
8#306 /AE 8#307 /Ccedilla 8#310 /Egrave 8#311 /Eacute
8#312 /Ecircumflex 8#313 /Edieresis 8#314 /Igrave 8#315 /Iacute
8#316 /Icircumflex 8#317 /Idieresis 8#320 /Eth 8#321 /Ntilde 8#322 /Ograve
8#323 /Oacute 8#324 /Ocircumflex 8#325 /Otilde 8#326 /Odieresis 8#327 /multiply
8#330 /Oslash 8#331 /Ugrave 8#332 /Uacute 8#333 /Ucircumflex
8#334 /Udieresis 8#335 /Yacute 8#336 /Thorn 8#337 /germandbls 8#340 /agrave
8#341 /aacute 8#342 /acircumflex 8#343 /atilde 8#344 /adieresis 8#345 /aring
8#346 /ae 8#347 /ccedilla 8#350 /egrave 8#351 /eacute
8#352 /ecircumflex 8#353 /edieresis 8#354 /igrave 8#355 /iacute
8#356 /icircumflex 8#357 /idieresis 8#360 /eth 8#361 /ntilde 8#362 /ograve
8#363 /oacute 8#364 /ocircumflex 8#365 /otilde 8#366 /odieresis 8#367 /divide
8#370 /oslash 8#371 /ugrave 8#372 /uacute 8#373 /ucircumflex
8#374 /udieresis 8#375 /yacute 8#376 /thorn 8#377 /ydieresis] def
/\$F2psBegin {\$F2psDict begin /\$F2psEnteredState save def} def
/\$F2psEnd {\$F2psEnteredState restore end} def
\$F2psBegin
1 setmiterlimit
0 slj 0 slc
% end of header
%!FontType1-1.1: Code39JK 001.000
%%CreationDate: Thu Feb 22 12:20:33 2001
%%VMusage: 10488 6784
%
% This Type 1 PostScript font implements the Code 39 bar code.
% Copyright (C) 2001 Jan Karrman. All rights reserved.
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
%
11 dict begin
/FontInfo 10 dict dup begin
/version (001.000) readonly def
/Notice (Copyright (C) 2001 Jan Karrman. All rights reserved.) readonly def
/FullName (Code 39 JK) readonly def
/FamilyName (Code 39 JK) readonly def
/Weight (Medium) readonly def
/ItalicAngle 0 def
/isFixedPitch false def
/UnderlinePosition 0 def
/UnderlineThickness 0 def
end readonly def
/FontName /Code39JK def
/Encoding 256 array
0 1 255 {1 index exch /.notdef put} for
dup 32 /space put
dup 36 /dollar put
dup 37 /percent put
dup 42 /asterisk put
dup 43 /plus put
dup 45 /hyphen put
dup 46 /period put
dup 47 /slash put
dup 48 /zero put
dup 49 /one put
dup 50 /two put
dup 51 /three put
dup 52 /four put
dup 53 /five put
dup 54 /six put
dup 55 /seven put
dup 56 /eight put
dup 57 /nine put
dup 65 /A put
dup 66 /B put
dup 67 /C put
dup 68 /D put
dup 69 /E put
dup 70 /F put
dup 71 /G put
dup 72 /H put
dup 73 /I put
dup 74 /J put
dup 75 /K put
dup 76 /L put
dup 77 /M put
dup 78 /N put
dup 79 /O put
dup 80 /P put
dup 81 /Q put
dup 82 /R put
dup 83 /S put
dup 84 /T put
dup 85 /U put
dup 86 /V put
dup 87 /W put
dup 88 /X put
dup 89 /Y put
dup 90 /Z put
readonly def
/PaintType 0 def
/FontType 1 def
/FontMatrix [0.001 0 0 0.001 0 0] readonly def
/UniqueID 5119294 def
/FontBBox [0 0 360 800] readonly def
currentdict end
currentfile eexec
f983ef0097ece636fb4a96c74d26ab84185f6dfa4a16a7a1c27bbe3f1156aea6
98df331278ddd83a95bfe3721babb069504235a8fca9f8012c70beaa7df68b59
3bd9d4efa3ace1dece221596c4dfc26c5c23e53e56473f4d3d6af6250e05d49b
73f7a3256c4c7009b943617e186e6e406c0452dfa948d4c47a33656eb964cb53
dee08929b0003bd7ddaccd7fa8af1d9d747bfddcfef440f31be75ad6f19c971e
720977e21ff5df9eb46cffc8637d5b56f558338bcfaa175db8707efb880ccfa5
be787a0185c3164b2213ed9d4933bfb0142b34cf3296a02575d97c10fe982329
3233e30900b1b428c0429f1922d7ec6f01b8d1a72d48f3e093a40a00ffa768e2
d3e1162c36d8cf116197ee43f5301c217e6f9726917a19d55fd1e8d25e950459
ff7e42293071631ee92822a5f9f812fa59252b169861541bc334cff66cbb2d61
52330092f967f0afe830c391f42739ec786a5e5bbe7b7211120e9acf4c32d9ea
97c44b45b3f6d3906afd46dc59ebc162dd11d0a03e32eb21ecc44a1c7f68a6fa
2da8f683444c371c1b223bdc8f22d81fdba645d4aac65208590b5df9358ef42c
7bdc233984ccfd30846b35941be9c3ac378d34ffa48e9e425c1ab97d4c122677
7ff90303deadc59a42e51826dc065a6cc2e708e4cc66f604f52076e022cefce7
7223a0f12090d4c370dbb8680834a09b83200f66822a15d9287d786326762b9e
86709e3f2775d350eec892870b3b34eda9315924705fabf8ebeab98ae22449d3
2e9104f73511b5d8c6b77fe1f2a23042360baa7cc12863ff9577dba7e2b193a3
437338ce1b4715f5f72e5b0621c12774a38eefc64e6ec560809f68ef25d3770a
90c9f106f9574232f62a98d6a6d564b39554ce6fbc2469ab3963f0e81adefcb9
c13d9d8e005419ed384c80bd4f53e0bf55efa1632c0ffed21488373639267cee
1412d4ceed8a9106d75ba9781383428f0ac5b8f9e5b130a53f708ed004c11458
8277fc93fadaf0072baad1974097704a35828af5e9ea2231fa79ded4c93c6465
8cfff250066d3094d027af1ff377117db766c2b6d84f4a0ff18cb75de0294ecb
bbc530d74620e71ed422b48b54489f9ba454260283842c0601b9a15cf3210eb6
d366e0ea5df852255f95ebc6e144676c53f6c1936868591243451b199ef64978
6555f5d89a1c02f8c1c245b04fa691c71a46e0e7c26c3c27f26e1c8aae84dee6
c880e76ae9e6050c77ab738a90573137acc1ea3678647391581fd63bf2c94337
16e4a47e377f24126dc9ecc9f9d120a96bf04a8f9080e4fbfdc1f93962074c41
73591895540961a61b4ebf2189e19c682df3bf5e678491161e012e1a39d8b0ee
56953d9080d87d90bb7c85a73953b8a2336638f17fc07bdabed372d2278ab84a
bc40440d5b685cfe6497116c736ce9813aaed18486c47832833cecee650bf780
085f19dd5ba5c03364c051fe402b16560b508b0e4b60c7daec677f305ad303b4
2ef4656506b8ddc1cd1998d0605173020d84edd1010257e962a9d8c62096c2a9
a461225bd98372f6336a7289fe3f2852573c77e376a545e5847bfbc1558128ba
b149d35fef3a7616952420958a5b2772d4443c52d507552694281de81372e742
5b3c304c4e4aa53904c8f0e848acea7e904959205563c2155f48a5ceb50126bd
1e5b619ecc05cda3489d11687667dafa8059d0adc8fd3b1f25e5e70ec37df8fe
7444249d7c806249fbf5e45bff855bda025da96dc80a1fe921508d39e9e2b3e8
442538a8a528ac7e4625e569a15717f70fa619113c9f9f69ab5f16b86dcccbbd
cf6bcdff94020acf1c510c844fc3427932281a21bdf13a49f8db6a3e888bb4d8
2060165e08d3428f5f44f32553584421ddbba06bbf874352b30cc25104ffad8b
9378574753ee8af2e29884445a8ea1cf2c394e7c905c9f5578c48c1f3d9bd135
8f3b26b924818e3a5b0e3b90af115dd8154997dde42863be62fe49942cdcfeec
edcb38dabd23afbe20d9f18700345da0e4f3a1647fc2b29cab8209a964f0032c
dc45fad7edb94e1dc574ac9a702cae006d86c0999c107dd5129f6cecceb6e1b8
35b53eaf32ca00bedebfa2bffc01c3733edb2513965f95681d0ab13f2188e328
9773b193b7ef7fe2a6927f898f8098b3f61db4dbcddcc584b397f4b34ff3155e
3a2f8914e521bef2bedc8412984a6ee9e8f778fc41204177a6392b510ba3632c
801485e3216e8bed24254259d41066d884c6ede447b3e61803e7330fc6840f19
69beb27e73b2a88836bddce8a1399e28f9dbaff4c0d51c4e58dc6e8837be0218
05846d0afd5a29c166bbaa4d767ad1d0e6549f0c18597bc701afb56b80fce498
16d006103e14c901e94771b3cee1135f180d121dd3953207011b280da7831edb
03a7170bd937fed6d337ff2e364a6573abff53144aa21ab91e7aa07d20bbf195
96cff361b33917290f4c2a44191943b78b4d384143e18e1b30db604a98e4d80e
0e238aef92d8964072436a6e084f86e718f0227b146de41aed0478164ded09ef
81139ee0cfee8cfa6e8fdde79d2351f3f406271e30f41432b016a006883b789c
876d9e0cfef335e78d596e1b1c217074363a55fc5261766db0541acc9e1540d3
a7a3bbe6591b25866be0416172ad244eaf1c7a3b373573bf17de55fcded55d13
45711e27248ab0e155fab1cb163a7d4c0207fc7e6ab4012ffeb7837f66b3f526
be1f3762ae9e4bbe20768c88e6bf86719a94fc323cc22db7bef746cdd87c2fba
69a8ac401dec2f33a2d6a2c25bfb2c2e4c1d0a02737764afdc71d6c5b9cda9cc
59690208c68f92c91a7a21d090584679245801b507a184c63deba8ae147e3cc1
8d9f5ed12a2e3b3086ecdb4d03abd6123212227df157d06b8ea2bacb319f06de
87625fb7a949fce79ca3f4ba09b71f00365d05c4fd583ca71700c502b3505098
6d359100adad44cc2331b9cceac941e91f74467b910b772da9a8ddec760ded34
077eeec300a0444313e4dbc7d2b29176bb34e8007f5cc3ac9586cceb56a317e1
18bb69205b313361f7feceac84d688ee70d0ab3c5af9428d0b1b373adf018894
3ba8e82d017f2855dd94c37dcc2c3a5661fc34db09e6fd3ab0e3019cfe4a4a8d
b01d6a48e74fc4aba7fb1bb9e8af6f476188fe75deb7da278d3b597c754368a9
d9b15c3319a7fd66370a4abddc47e428f884b4d359a7bcba799b2b1f8a6629d3
5385caee9c04dbd5b6521f621473a62020f814ecbbbcc300e6a8cb1d729529b3
9528e6872380e4777abfc41f437dda52759a251b93174298f5fc5752862fd62c
865db358d52384e6b9649556a8b8a84f56393cfac7d8ef532cf911a76a3f996f
2a747d0cb97798bcccc8cfa31cd3de4bc923e8a94369943e6cc34aeec4d99dbe
5f02efd96263f7e639d08998742ef4d03f786e58b9b76e83a05b1fd3cc952b44
049824cf808e95d868031089bf2606f77b39c8b82f0712eeefde6952ef7ed510
b468c03b3fe288e20f87538c9980301be5f0753611ffee00ada6436b8978b632
ad51185337a3862bebfafa0af6c5f276bafea34d202669787c3f8003c66c2871
338dde6b629d9e8e94bc2bbc5583e1196f36e179de3d4861fd4dbb461e49b2a1
a775c12f8ab1a733a7597d6b2801020b7241babe073b8ecd1b6ac5ae872ddd3e
cb55324f6006c8d8979052fa8f2b4c13435488064c3ca2262dc75d3aa62e8a43
9a723cc8c28c8076f3ed0e981845619e58c3d8e935a73ec8c24f8e4213880a2a
69e1b61e10ed165826836d454db0a9233cad93e61a865035ffb446a53638f6a6
0ae72bf6948ae2f80f337eabc92a7113dfe35c4de690c71349a5bdf18c1bc4e3
47d2bbec3318fa751d4978922cb0653d9ba73ba3b430b153461e2deaec27dfaa
39f7eaa8fae31bd85b7e9c88e4d9144930bca23d3e7e0cc5235b295bc597a12f
71868bca353e31d728771ee6e7cc9e1c3b69472a39a9b1a4b50f321237daf0ff
4ed8abeea87a8ad49f1876f6d51c88c6dec98ba9da1c393ac0adf7693fb14b19
1d3ecad5b10a45d1a679f90f4cebf91454d89f7e2a0c5f2e474fcb095cfab2b1
5bcc4b824d6860b5fe1505197e3a76773d0a737bd3fb568cd7d20b32e8d98613
9d2973d000d180d77f907ba8c1ad684236e84aec0089e800ac98b126ffa78ad9
16c3053e10ed7d8697fa6189327e9018f44370a8a3399d320e589f2b4bc2bd4c
f742b5c98b808c29c9e7442398ad0407494284ca2addf340ce5b51e0c5792589
70d84434f2869055f84917e9a64787c5f5333b4cf78887a73836f14e6f58c980
2c90ff4669b97267394826d854f35cb5abe96fe46d558fbc02a371e26972aff3
2303941bcc1913ea8e90bbd916ad22745820f52ba160db1c36b811d927924cd6
9784b3617cd20e8df06c5cf7dbcea9a59d74bd5de2595afdf90e37
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
cleartomark
%0.06299 0.06299 sc --we can be more exact
72 1143.0000 div dup sc
/Code39JK /Code39JK-iso isovec ReEncode
/Code39JK-iso ff
/BaselineFrac 0.20 def % reasonable default
dup /FontBBox known
{
dup /FontBBox get
% some fonts have { .. }, others have [ .. ], get works always
% font [-x-y+x+y] |head
dup 1 get % font [-x-y+x+y] -ymin |head
neg % font [-x-y+x+y] ymin |head
dup % font [-x-y+x+y] ymin ymin |head
3 -1 roll % font ymin ymin [-x-y+x+y] |head
3 get % font ymin ymin ymax |head
add % font ymin ytot |head
dup 0 eq % font ymin ytot tr/fal |head
{ % (if true, ytot==0)
% font ymin 0 |head
pop pop % font |head
% Leave BaselineFrac at default (above)
}
{ % (if false, ytot!=0: we can divide)
% font ymin ytot |head
div % font yfrac |head
/BaselineFrac exch def
% BaselineFrac now fraction of total y-to-M height
} ifelse
% font |head
} if
% Print out the BaselineFrac. Try with Times-Roman or Symbol
%dup 150 scf sf
%0 1710.0 500 sub m
%(BaselineFrac = ) sh % Duh, vertically mirrored. don't care.
%/str 200 string def
%BaselineFrac str cvs sh
% Makefont now does all at once: scaling, stretching, slanting,
% and hightening, so that cursorpoint is real bottom instead of
% baseline, plus any manual move-up.
% (font still on stack)
[ 247.6499999238 2 mul
0
0 247.6499999238 mul
247.6499999238
0
247.6499999238 BaselineFrac mul 247.6499999238 0 mul add
] makefont sf
% Thanks to Practical Postscript
% and http://atrey.karlin.mff.cuni.cz/~milanek/PostScript/Reference/
% ...oh okay. So that was cleverly ripped from Adobe's PS RefManual,
% such as http://www-cdf.fnal.gov/offline/PostScript/PLRM3.pdf
col0
45000 1297.2500000127 m
gs 1 -1 sc
(\052$1\052)
dup sw pop 2 div neg 0 rm sh gr
/Arial ff
[ 247.6499999238 1 mul
0
0 247.6499999238 mul
247.6499999238
0
247.6499999238 BaselineFrac mul 247.6499999238 0 mul add
] makefont sf
45000 1557.6000000381 m
gs 1 -1 sc
($1)
dup sw pop 2 div neg 0 rm sh gr
\$F2psEnd
rs
showpage
%%Trailer
%EOF" | dyeps2pbm 128 | pnmcrop -white -top -bottom | pbm2lmpc -i0 -p2 -c ; cat /usr/local/share/dymo/feed-endmargin.pbm.lm) | lp -d DYMO
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment