Barcode Xpress for Linux v13.9 - Updated
Create a Barcode
Developer Guide > How To > Create a Barcode

The first step to creating a barcode is to decide what type of barcode to use and what the contents will be. This is done by creating a BX_CreateParameters structure.

Set the type of barcode and the value you want to create. Barcode types that can be written are listed in the Supported Barcode Types section.

For a full list of properties see the BX_CreateParameters structure.

To create a bitmap image file of the barcode call the BX_create_file function.

To create an in memory bitmap structure of the barcode call the BX_create_dib function.

The following code example illustrates creating a 1D barcode.

    //create a copy of the default parameters.
    BX\_CreateParameters bxCreateParams = BX\_DefaultCreateParameters;
    //set some of the 1D parameters:
    bxCreateParams.Params1D.CheckSum = false; //don't print the checksum for barcode types that have an optional checksum character.
    bxCreateParams.Params1D.TextNotchPercent = 25;
    // create the status and results variable to capture the results:
    BX\_CreateResult createResult;
    BX\_Status resultOfCreation = BX\_Status\_OK;
    // initialize the error count:
    createResult.ErrorCount = 0;

       //call BX\_create\_dib or BX\_create\_file to create a barcode image:
    resultOfCreation = BX\_create\_file(params, fl, &createResult);

       // check that the file was created successfully.
    if (createResult.ErrorCount == 0 && resultOfCreation == BX\_Status\_OK)
    {
        printf("Successfully created file \\"%s\\".\\n", fl);
    }
    else
    {
        ///there was an error of some kind:
        printf("Failed to create file %s. ErrorNumber = %d\\n", fl, resultOfCreation );
        //print the error details:
        for (resultLen; resultLen < createResult.ErrorCount; resultLen++)
        {
            printf("Error creating file file %d: %s.\\n", resultLen, createResult.BarcodeErrors\[resultLen\].errorID);
        }
    }

Is this page helpful?
Yes No
Thanks for your feedback.