Skip to Content
avatar image
Former Member

Questions about barcodes printed using Crystal Reports

If you create a barcode using Crystal Reports and output it to PDF, the barcode scanner will recognize the barcode normally.

However, when exportting to Word, the barcode is not recognized by the barcode scanner.

Even if you look at the output, the results of the barcode in Word and PDF are different.

I am using Visual Studio 2008 and the Crystal Report product version is

Windows 7, 10 the same phenomenon appears.

The font uses CCodeI2of5_S4.

I can not find a solution to the problem of barcode output when exportting to word.


Dim data as string
Dim chk as Number

'Replace "12345678" with your data field here
data = "12345678"

'Set Check Digit to 0 or 1
chk = 0

Dim Result As String
Dim datalength as Number

Dim barcodechar As String
Dim barcodevalue as Number

Dim filtereddata As String
Dim filteredlength As Number
Dim transformdata As String
Dim cd as string

Dim x as number
Dim z as number

cd = ""
transformdata = ""
Result = ""
datalength = Len(data)

'Filter Input
For x = 0 To datalength - 1
barcodechar = Mid(data, x + 1, 1)

If AscW(barcodechar) <= AscW("9") And AscW(barcodechar) >= AscW("0") Then
Result = Result + barcodechar
End If

Next x

filtereddata = Result
filteredlength = Len(filtereddata)

If chk = 1 Then

If filteredlength > 253 Then
filtereddata = Left(filtereddata, 253)

End If

If (Len(filtereddata) Mod 2 = 0) Then 'Make it odd number of digits
filtereddata = "0" + filtereddata
End If

Dim generateCheckDigit_I2of5 as String
Dim toggle as number
Dim sumx as number
Dim lastcharpos as number
Dim ResultVal as number

barcodechar = ""
barcodevalue = 0
toggle = 1
sumx = 0

generateCheckDigit_I2of5 = ""

lastcharpos = Len(filtereddata) - 1
For x = lastcharpos To 0 Step -1

barcodechar = Mid(filtereddata, x + 1, 1)
barcodevalue = (AscW(barcodechar) - 48)

If toggle = 1 Then
sumx = sumx + (barcodevalue * 3)
toggle = 0
sumx = sumx + barcodevalue
toggle = 1
End If
Next x

If ((sumx Mod 10) = 0) Then
ResultVal = AscW("0")
ResultVal = (10 - (sumx Mod 10)) + AscW("0")
End If

generateCheckDigit_I2of5 = Chr(ResultVal)
cd = generateCheckDigit_I2of5


If filteredlength > 254 Then
filtereddata = Left(filtereddata, 254)
End If

If (Len(filtereddata) Mod 2 = 1) Then 'Make it even number of digits
filtereddata = "0" + filtereddata
End If

End If

filtereddata = filtereddata + cd

Dim getI2of5Character as string
Dim inputvalue as Number
Dim num as number

Result = ""
num = 0
For x = 0 To Len(filtereddata) - 1 Step 2

num = Val(Mid(filtereddata, x + 1, 2))

getI2of5Character = ""
inputvalue = num
If (inputvalue <= 90) And (inputvalue >= 0) Then
inputvalue = inputvalue + 32
ElseIf (inputvalue <= 99) And (inputvalue >= 91) Then
inputvalue = inputvalue + 100
inputvalue = -1
End If
getI2of5Character = Chr(inputvalue)

Result = Result + getI2of5Character

Next x

Result = "{" + Result + "}"

formula = Result

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Feb 09, 2018 at 07:07 PM

    How the results of the barcode are different in Word and PDF? Is the bar truncated on a side or at the bottom?

    Does it work with another Font?

    Note, when report exported to PDF, the font (if embedable) gets embedded into the PDF file. You can see what embedded in File > Properties > Fonts tab. In case with Word, the font or closest to it is loaded from the Windows Fonts.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      In Word and PDF, the result of the barcode is printed without truncation.
      The following bar codes are the result of outputting the same bar code number.
      The PDF barcode is recognized by the barcode scanner and the Word barcode is not recognized.
      Both Word and PDF fonts were output as CCodeI2of5_S4.
      No other fonts were found that work with Word.

  • Feb 13, 2018 at 05:39 PM

    You wrote "No other fonts were found that work with Word".

    Does it mean if you create a text manually in Word and then change it to CCodeI2of5_S4 font and it will generate a barcode that scanner can read?

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 14, 2018 at 09:57 PM

    CR 11.5 is not supported in VS 2008, only one that was is CR Basic (version 10.5) included with VS.

    Or CR 2008 would work with VS 2008.

    To upgrade to the ONLY supported .NET SDK go here, requires VS 2010 -> 2017:

    Now the font issue, I download that font from this link:

    I get the same results, exporting to PDF and the barcode can be scanned. I have a scanner for testing. I used your formula in CRD to generate the barcode.

    Exporting to Word and the View and print out has some extra bars attached to the end of the barcode.

    So I exported to PDF, which can be scanned. From PDF Writer I then exported the report to Word and Word again appended some extra characters onto the end of the barcode.

    So this is not a CR issue, contact Microsoft and get them to fix this Font issue.


    Add comment
    10|10000 characters needed characters exceeded