def example_CreatePDF(): ''' create a pdf file ''' printer = os.getenv("PRINTER") if printer is None: print( "examplecreatePDF: environment variable PRINTER not defined, returning" ) return PySpectra.cls() PySpectra.delete() PySpectra.setTitle("Create PDF file and send it to the printer") PySpectra.setWsViewport("DINA5") scan = PySpectra.Scan(name='PDF Output', nPts=100, xMin=-1., xMax=1., xLabel='Position', yLabel="Counts") scan.y = np.sin(scan.x) PySpectra.setWsViewport("DINA4") PySpectra.display() PySpectra.createPDF(flagPrint=True) return
def createHardCopy(printer=None, flagPrint=False, format='DINA4'): ''' create postscript/pdf file and send it to the printer ''' fName = None if spectraInstalled and useSpectra: Spectra.gra_command(" set 0.1/border=1") if flagPrint: if printer is None: raise ValueError( "graPyspIfc.createHardCopy: flagPrint == True but no printer" ) Spectra.gra_command( " postscript/%s/redisplay/nolog/nocon/print/lp=%s" % (format, printer)) else: Spectra.gra_command(" postscript/%s/redisplay/nolog/nocon/print" % (format)) Spectra.gra_command(" set 0.1/border=0") Spectra.gra_command(" postscript/redisplay/nolog/nocon/print/lp=%s" % printer) else: fName = PySpectra.createPDF(flagPrint=flagPrint, format=format) # # necessary to bring pqt and mpl again in-sync, mind lastIndex # PySpectra.cls() PySpectra.display() return fName