yan74 / afplib

JAVA Library for reading & writing AFP (Advanced Function Presentation) Files.
Apache License 2.0
37 stars 22 forks source link

Not an Issue: How to create Barcode in AFP #13

Closed SaravanaAnandan closed 7 years ago

SaravanaAnandan commented 7 years ago

Hi, Could you please tell me how to create AFP file with Barcode using AFPLIB?

Thanks & Regards, Saravana Anandan

yan74 commented 7 years ago

Hi @SaravanaAnandan,

please have a look at the BCOCA specification (you may find it at afpcinc.org). I added an example on how to create a 2D datamatrix code at

https://raw.githubusercontent.com/yan74/afplib/d96be8bbcd962d733b8c212015783802ab7699f3/org.afplib.samples/src/main/java/org/afplib/samples/snippets/CreatePageWithBarcode.java

to get you started. This is how it looks like:

bcoca

SaravanaAnandan commented 7 years ago

Hi, Thank you so much for the information. Can you please tell me how to create USPS bar code like the one in the attached image. Thanks & Regards, Saravana Anandan

usps bar code

yan74 commented 7 years ago

I believe this can be achieved by changing the barcode type:

    BDD bdd = new AfpBuilder()
            .with(AfplibPackage.BDD__UBASE, BDDUBASE.CONST10IN_VALUE)
            .with(AfplibPackage.BDD__RESERVED, 0)
            .with(AfplibPackage.BDD__XUPUB, 3000) // 300 dpi
            .with(AfplibPackage.BDD__YUPUB, 300)
            .with(AfplibPackage.BDD__XEXTENT, 65535)
            .with(AfplibPackage.BDD__YEXTENT, 65535)
            .with(AfplibPackage.BDD__RESERVED2, 0)
            .with(AfplibPackage.BDD__TYPE, BDDTYPE.CONST_POSTNET_VALUE)
            .with(AfplibPackage.BDD__MOD, 1)
            .with(AfplibPackage.BDD__LID, 255)
            .with(AfplibPackage.BDD__COLOR, BDDCOLOR.CONST_DEVICEDEFAULT_VALUE)
            .with(AfplibPackage.BDD__MODULEWIDTH, 255)
            .with(AfplibPackage.BDD__ELEMENTHEIGHT, 65535)
            .with(AfplibPackage.BDD__MULT, 1)
            .with(AfplibPackage.BDD__WENE, 230)
            .create(BDD.class);

and of course the data

byte[] data = new byte[] { 0xf1,  0xf2,  0xf3,  0xf4,  0xf5,  0xf6,  0xf7,  0xf8,  0xf9 };

I haven't verified so try and see if it works.

yan74 commented 7 years ago

@SaravanaAnandan,

does this work for you?

SaravanaAnandan commented 7 years ago

Hi, It is working. Thank you so much for your help.

Regards, Saravana Anandan

On May 30, 2017, at 12:32 PM, Yan Hackl-Feldbusch notifications@github.com<mailto:notifications@github.com> wrote:

@SaravanaAnandanhttps://github.com/saravanaanandan,

does this work for you?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/yan74/afplib/issues/13#issuecomment-304951317, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AbevxQsYdzmOW8-kZ4vO5vpt3DNERPqhks5r_FKPgaJpZM4NhAVN.