#!/usr/bin/perl # labelfmt # format bib db so that we can print labels # gets standard sqlite text input: # 663|9785170271955|Wat 3a Warom (russisch)|B. Barhep|computer|1998|1221413368| use strict; use warnings; my $labelfile = "label"; $_ = <>; # only read one label at the time my ($id, $i, $tit, $a, $g, $y) = split /\|/, $_; # format the isbn number a bit my @i = split //, $i; local $"=""; $i = $i[0] . "-" . "@i[1..6]" . "-" . "@i[7..12]"; open TEX, ">", $labelfile . ".tex"; # yes, unsafe select TEX; print <<'EOF'; \documentclass{memoir} \setstocksize{36mm}{89mm} %% dymo 99012 paper \setlength{\headheight}{0mm} \setlength{\headsep}{-28mm} \setlength{\textwidth}{72mm} %% -6 mm \setlength{\textheight}{28mm} %% -6 mm \setlength{\oddsidemargin}{-16mm} \setlength{\parindent}{0mm} \begin{document} \pagestyle{empty} \sffamily EOF printf "\\textbf{%.40s}\n\n", $tit; printf "\\qquad %.30s \\\\\n\n", $a; printf "\\qquad\\textbf{%.30s} \\\\\n\n", uc $g; printf "ISBN: \\textbf{%s}\\hfill%d\n", $i, $y; print '\end{document}', "\n"; close TEX; # now we make the pdf - after we clean up, the mess if (system("pdflatex $labelfile") != 0) { warn "Er ging iets falikant verkeerd"; } else { system("lpr -Plabel $labelfile.pdf"); } unlink $labelfile . ".log", $labelfile . ".aux", $labelfile . ".tex"; unlink $labelfile . ".pdf";