Changes

Jump to navigation Jump to search
and the result :<br/>
[[Image:Testgs.png|900px]]
 
Another example:<br/>
here we use a library to generate barcodes [http://www.terryburton.co.uk/barcodewriter (see here)] .
<textcode>
\startluacode
function epstopdf(epsin,pdfout)
require("python")
gsmodule = python.import("testgs")
ghost = gsmodule.gs()
ghost.appendargs('-q')
ghost.appendargs('-dNOPAUSE')
ghost.appendargs('-dEPSCrop')
ghost.appendargs('-sDEVICE=pdfwrite')
ghost.InFile = epsin
ghost.OutFile = pdfout
ghost.run()
end
 
function barcode(text,type,options,savefile)
require("python")
gsmodule = python.import("testgs")
 
barcode_string = string.format("%%!\n100 100 moveto (%s) (%s) %s barcode showpage" ,text,options,type)
 
psfile = string.format("%s.ps",savefile)
epsfile = string.format("%s.eps",savefile)
pdffile = string.format("%s.pdf",savefile)
 
temp = io.open(psfile,'w')
print(psfile)
temp:write(tostring(barcode_string),"\n")
temp:flush()
io.close(temp)
ghost = gsmodule.gs()
ghost.rawappendargs('-q')
ghost.rawappendargs('-dNOPAUSE')
ghost.rawappendargs('-sDEVICE=epswrite')
ghost.rawappendargs(string.format('-sOutputFile=%s',epsfile))
ghost.rawappendargs('barcode.ps')
ghost.InFile= psfile
ghost.run()
end
\stopluacode
 
\def\epstopdf#1#2{\ctxlua{epstopdf("#1","#2")}}
\def\EPSfigure[#1]{%lazy way to load eps
\epstopdf{#1.eps}{#1.pdf}%
\externalfigure[#1.pdf]%
}
 
 
\def\PutBarcode[#1]{%
\getparameters[bc][#1]%
\ctxlua{barcode("\csname bctext\endcsname","\csname bctype\endcsname","\csname bcoptions\endcsname","\csname bcsavefile\endcsname" )}%
\expanded{\EPSfigure[\csname bcsavefile\endcsname]}%
}
 
\starttext
\startTEXpage
\startcombination[2*2]
{\PutBarcode[text={CODE 39},type={code39},options={includecheck includetext},savefile={TEMP1}]}{\ss code39}
{\PutBarcode[text={CONTEXT},type={code93},options={includecheck includetext},savefile={TEMP2}]}{\ss code93}
{\PutBarcode[text={977147396801},type={ean13},options={includetext},savefile={TEMP3}]}{\ss ean13}
{\PutBarcode[text={0123456789},type={interleaved2of5},options={includecheck includetext},savefile={TEMP4}]}{\ss interleaved2of5}
\stopcombination
\stopTEXpage
\stoptext
</texcode>

Navigation menu