Open main menu

Changes

* convert an existing eps / ps file in pdf
* use a program in postscript that make something e.g. a barcode /label generator
 
For the first case, we consider an implementation of eps2pdf, being ps2pdf the same .<br/>
Actually there is not a python binding of ghostscript, so we build a simple wrapper
ctypes module.
<pre>
</pre>
 
The tex code
<texcode>
\startluacode
function testgs(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
\stopluacode
 
\def\epstopdf#1#2{\ctxlua{testgs("#1","#2")}}
\def\EPSfigure[#1]{%lazy way to load eps
\epstopdf{#1.eps}{#1.pdf}%
\externalfigure[#1.pdf]%
}
 
\starttext
\startTEXpage
\startcombination[2*1]
{\EPSfigure[tiger]}{\ss tiger.eps}
{\EPSfigure[golfer]}{\ss golfer.eps}
\stopcombination
\stopTEXpage
\stoptext
test-ghostscript.tex (END)
</texcode>