`
hyz301
  • 浏览: 370648 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

FoxBarcode(一维码生成库)使用教程

阅读更多

FoxBarcode使用教程

FoxBarcode100%VFox,它提供了一个使用不同条码特征生成图像文件的工具,它应用于VFP表单和报告,或出口到其他应用程序。

Project Manager: VFPEncoding (*)

(*) VFPEncoding are  Guillermo Carrero (RIP) (Barcelona, Spain) and Luis Maria Guayan (Tucuman, Argentina)

 In Memoriam Guillermo Carrero (Feb 05, 1961 / Jan 14, 2013)

特性

FoxBarcode支持以下条码象征学:代码128(自动、ABC),39,39码扩展(ASCII),93年代码,代码93扩展(ASCII),标准25、交叉25EAN-8,EAN-13,UPC-A,UPC-E(EANUPC 2/5数字补充剂),ITF-14,GS1 / UCC / EAN - 128,Codabar,代码11,MSI / Plessey PostNet,MS4SCC,KIX-Code Telepen,跟踪Pharmacode和两个跟踪Pharmacode。现在支持二维码FoxBarcodeQR补充。

FoxBarcode 支持以下图片类型: JPG, BMP, GIF, PNG and TIFF

FoxBarcode使用gpImage2(http://sites.google.com/site/gpimage2)类生成图像,它的作者是Alexander Golovlev(俄罗斯)和塞萨尔 (巴西),基于GDI +和需要gdiplus.dll

FoxBarcode兼容所有版本6.0版本的VFox

属性

FoxBarcode允许更好地控制条形码的生成图像能够定制以下属性:

 nImageHeight: Height in pixels of the image.

 nImageWidth: Width in pixels of the image. Now can set the property

 nAlignBarcode: Allows to align the barcode on the left, center or right of the image.

 nResolution: Image resolution in DPI.

 nRotation: Rotate the image. (0 = 0°, 1 = 90°, 2 = 180°, 3 = 270°)

 cImageType: Type of the generated image ("JPG", "GIF" "PNG", "BMP", "TIF")

 cImageFile: Name the image file generated. If not specified, it generates a random file name in the folder Windows temporary files.

 cText: Text encoding.

 nAlignText: Alignment of human-readable text. (0 = Left, 1 = center, 2 = Right)

 lShowHumanReadableText: .T. whether to display the human-readable.

 lShowCheckDigit: .T. whether to display the check digit on the human-readable.

 lShowStartStopChars: .T. if it shows the start and end characters in human-readable.

 cFontName: Name of the source of human-readable.

 lFontBold: .T. if the source of human-readable is Bold.

 lFontItalic: .T. if the source of human-readable is Italic.

 nFontSize: Font size of the human-readable. (Recommended = 8 or 9)

 nFontColor: Color of the human-readable source. (Recommended = Black = RGB (0,0,0)).

 nBackColor: The background color of the image (Recommended = White = RGB (255,255,255)).

 nBarsColor: Color of the bars (Recommended = Black = RGB (0,0,0)).

 nBarcodeType: Type bar code symbology. See the list of supported barcodes and ID

 cSet128: Set of Code 128. ("A", "B", "C" and AUTO with "*" chararacter)

 cSupplementalText: Supplementary Text EAN and UPC codes.

 lAddCheckDigit: .T. if you calculate the check digit. In symbols, where the check digit is mandatory, not taking into account this property.

 nBearerBar: supporting frame type, only in the ITF-14 symbology. (0 = None, 1 = Rectangle, 2 = Top & Bottom)

 lUseAppId: .T. FoxBarcode interpreter to code to GS1/UCC/EAN-128 Application Identifiers (enclosed in parentheses)

 nFactor: Magnification factor of the bar code. (1 .. 9)

 nMargin: Margin around the barcode

 nRatio: Relationship between the narrow bars and wide bars in the symbols that allow it.

 lDeleteTempFiles: Lets choose if delete or not the temporary folder and image files.

方法

生成的图像,只有一个方法应该调用生成条形码图像并返回生成的路径和文件名:

 BarcodeImage(cTextToEncode, cFileNameImage, cPropertyList): 编码文本并返回文件路径生成的条码图像。

所有参数都是可选的。

 cTextToEncode: 文本编码。

 cFileNameImage: 图像文件生成的名字。如果没有指定,它生成一个随机文件名在Windows临时文件的文件夹。

 cPropertyList: 第三个参数设置的所有属性在一行,由逗号分隔。

现在使用BarcodeTest()方法可以验证文本编码不需要生成条形码的图片:

 BarcodeTest(cTextToEncode, cFileNameImage, cPropertyList): 验证字符串编码不生成图像。

所有参数都是可选的像BarcodeImage()方法一样。

 cTextToEncode: 文本编码。

 cFileNameImage: 作为一个图像不是生成的,该参数是一个空字符串。

 cPropertyList: 第三个参数设置的所有属性在一行,由逗号分隔。

语言

帮助社区的VFP FoxBarcode消息翻译下列语言:

·         ENGLISH

·         SPANISH by VFPEncoding

·         CZECH by Martin Krivka

·         DUTCH by Koen Piller

·         GERMAN by Stefan Wuebbe

·         INDONESIAN by Samir H.

·         PORTUGUESE by Cesar Ch.

·         TURKISH by Ugur Yilmaz

·         FILIPINO by Glenn Gevero

·         FRENCH by Samir H.

·         SERBIAN by Michael Kopljan

·         ITALIAN by Roberto Saccomanno

你只需要定义编译器指令FBC_LANGUAGE FoxBarcode.prg与所需的语言文件。

#DEFINE FBC_LANGUAGE "ENGLISH"

 您可以添加更多的语言在母语翻译消息和发送电子邮件:vfpencoding@gmail.com

例子

下面是一个示例的代码来生成一个图像类型PNG条码代码128 C 100像素的高度和放大倍数2

*-- Create object
loFbc = CREATEOBJECT("FoxBarcode")

*-- Set the properties
WITH loFbc
  .cImageType = "PNG"
  .nBarcodeType = 110 & & Code 128
  .cSet128 = "C" & & Set 128 C
  .nImageHeight = 100
  .nFactor = 2
ENDWITH

*-- Generate image
lcImagen = loFbc.BarcodeImage("123456789012")

新第三个参数到BarcodeImage()方法,它允许您配置的各种属性,由逗号分隔。上面的例子一样,这种新方法。

*-- Create object
loFbc = CREATEOBJECT("FoxBarcode")

*-- Generate image with the properties
lcImagen = loFbc.BarcodeImage("","",[cText="123456789012", cImageType="PNG", nBarcodeType=110, cSet128="C", nImageHeight=100, nFactor=2])

下面是些用FoxBarcode生成的一些图片。

 



 



 



 



 

现在FoxBarcode支持代码EAN / UCC / GS1 128

 



 

下面是一个示例测试如果一个字符串是有效的编码EAN-8:

*--- Create FoxBarcode Object
LOCAL loFbc
loFbc = CREATEOBJECT("FoxBarcode")

*-- Generate a test (Ej: EAN-8 -> nBarcodeType = 150)
IF loFbc.BarcodeTest("123456", "", [nBarcodeType = 150]) 
  MESSAGEBOX(["] + loFbc.cText + ["] + " Ok", 64, "Example BarcodeTest()")
ELSE
  MESSAGEBOX(loFbc.cMsgError, 16, "Example BarcodeTest()")
ENDIF

包括表单上的条形码,你必须插入一个图片对象。随着条形码图像不存在在设计时,图像的图像属性的名称时,调用BarcodeImage()方法,例如刷新方法的形式,如下图所示:



 

包括报告上的条形码,你必须插入一个图像对象并设置属性的调用ControlSource BarcodeImage()方法和建议内容,保留形状如果图像大小不同于框架。



 

重要:在你运行报告和创建对象FoxBarcode,必须的变量声明为私有,在报告范围,如下:

PRIVATE poFbc
poFbc = CREATEOBJECT("FoxBarcode)
...
REPORT FORM MyReport

分布

唯一的文件需要分发给FoxBarcode正常工作:

 FoxBarcode.prg

 gpImage2.prg

这些文件位于源文件夹包含在下载文件中。

在实例化类FoxBarcode之前,您必须运行下面的语句:

SET PROCEDURE TO LOCFILE("FoxBarcode.prg"), LOCFILE("gpImage2.prg") ADDITIVE

Demo Form

FoxBarcode下载的示例表单,我们可以生成条形码的需求,和一个构建器的代码,我们可以将生成的代码复制到剪贴板粘贴到您的应用程序做好准备。

顶部的所有属性的形成有三个选项卡配置类FoxBarcode

条形码标签属性你输入的文本编码,这种象征意义,如果FoxBarcodecalculates校验位。图像的尺寸的条形码来配置:放大倍数,在保证金条形码,形象的高度,狭窄的比例和宽栏(符号允许这种变化)。条形码的旋转也从这个选项卡设置,以及一些特殊属性的符号。



 

通过符号的列表,当我们去选择的符号的简要描述,有效的人物和他们的更加普遍。




 

选项卡上的“Human-readable properties”,是否将显示,是否显示校验位,如果它显示字符的开始和结束的符号。理由的字体,大小和颜色设置选项卡。



 

选项卡"Image and colors"向我们展示了完整的图像文件的名称,这个属性可以作为参数传递或FoxBarcode类生成一个随机的文件名称。这里我们设置图像类型、分辨率(DPI),背景颜色和颜色的酒吧。



 

一旦你设置的属性,您可以点击按钮脚本生成器FoxBarcode自动生成必要的代码剪切并粘贴在您的应用程序。



 附上:FoxBarcode的源码链接
http://download.csdn.net/detail/hyz301/7596781

 

 

  • 大小: 5.7 KB
  • 大小: 5.5 KB
  • 大小: 4.9 KB
  • 大小: 6.3 KB
  • 大小: 12 KB
  • 大小: 17.8 KB
  • 大小: 75.5 KB
  • 大小: 28.3 KB
  • 大小: 22.5 KB
  • 大小: 20.3 KB
  • 大小: 19.3 KB
  • 大小: 28.6 KB
1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics