Re: [Gambas-user] Barcode.... Here ya go Hamilton...
Brought to you by:
gambas
From: sbungay <sb...@cs...> - 2007-04-27 16:02:18
|
One small change to the source... the following line; SHELL "rm -f " & user.Home & "/Barcode-" & pEncodeString & ".png" should read SHELL "rm -f " & "~/Barcode-" & pEncodeString & ".png" Stephen Bungay wrote: > This is the code (slightly modified from the original) for a Module (Mine is > called 'BarCodeFunctions') that should do the trick for you (and anyone else > who needs to make barcodes). > > Steve. > > ' Gambas module file > '*********************************************************************** > '* Author: Stephen Bungay. > '* Date: Sept 15 2006 > '* Creates a barcode PNG file using the GNU Barcode > '* tool and Imagemagic convert. > '* Returns a Picture object. > '*********************************************************************** > PUBLIC FUNCTION CreateBarCode(pEncodeString AS String, OPTIONAL pGiftCard AS > Boolean, pProduction AS Boolean) AS Picture > > DIM ShellString AS String > DIM PathString AS String > DIM BarcodePathString AS String > DIM ReturnValue AS Picture > DIM FilePrefix AS String > > ' Remove any previopusly created barcode. > SHELL "rm -f " & user.Home & "/Barcode-" & pEncodeString & ".png" > > ' This command creates a 128b barcode... > ShellString = BarCodePathString & "barcode -b " & pEncodeString & " -e > 128b -o " & "~/Barcode-" & pEncodeString & ".ps" > > SHELL ShellString > > WHILE NOT Exist("~/Barcode-" & pEncodeString & ".ps") > WAIT 0.4 > WEND > > ShellString = "convert " & "~/Barcode-" & pEncodeString & ".ps -crop > 205x80+7+703 " & "~/Barcode-" & pEncodeString & ".png" > > SHELL ShellString > > WHILE Exist( "~/Barcode-" & pEncodeString & ".png") = FALSE > WAIT 1 > WEND > > SHELL "rm -f " & "~/Barcode-" & pEncodeString & ".ps" > > WAIT 0.2 > > ReturnValue = picture.load( "~/Barcode-" & pEncodeString & ".png") > > RETURN (ReturnValue) > END > > '************************************************************************* > '* Print a barcode. > '* Takes a filename (PNG File created by the routine above) > '* as a parameter. > ' * Substutute your printer here. This one uses a > '* DYMO_Labelwriter_400 > '************************************************************************* > PUBLIC SUB PrintBarCode(pFileName AS String) > IF FormLauncher.Environment = ModuleConstants.cProduction THEN > SHELL "lpr -P DYMO_LabelWriter_400_USB_1 /home/kidscopos/Barcode-" & > pFileName > ELSE > Message.Info("Dev Environment In Use.\n" & > "Printing disabled.") > > END IF > > > END > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Gambas-user mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gambas-user > |