Barcode Generation - FPDF

0

I'm using classic asp generating the barcode in PDF.

I found a problem, in the function below, calculate the barcode with one more digit,

If someone can help you find the error thank you.

I made several changes but could not get the result. The value that should be displayed is: 481115243200001 however, presents:% with a zero% more.

I'm using this routine for the default 2 of 5

Sub fbarcode(Valor)
        Dim f, f1, f2, i
        Dim texto
        Dim p11
        p11=11
        Const fino = 0.4
        Const largo = 0.7
        Dim BarCodes(99)
if isempty(BarCodes(0)) then
    BarCodes(0) = "00110"
    BarCodes(1) = "10001"
    BarCodes(2) = "01001"
    BarCodes(3) = "11000"
    BarCodes(4) = "00101"
    BarCodes(5) = "10100"
    BarCodes(6) = "01100"
    BarCodes(7) = "00011"
    BarCodes(8) = "10010"
    BarCodes(9) = "01010"

    for f1 = 9 to 0 step -1
        for f2 = 9 to 0 Step -1
            f = f1 * 10 + f2
            texto = ""
            for i = 1 To 5
                texto = texto & mid(BarCodes(f1), i, 1) + mid(BarCodes(f2), i, 1)
            next
            BarCodes(f) = texto

        next
    next
    pdf.Text "30","225",texto
end if

xPos=55
p201=230
pdf.rect xPos, p201, fino, p11, "F"
xPos = xPos + fino + fino
pdf.rect xPos, p201, fino, p11, "F"
xpos = xpos + fino + fino


For n = 1 To Len(valor_barras) Step 2
    cASC = cint(Mid(valor_barras, n, 2))
    For i = 1 To 10 Step 2
        If Mid(BarCodes(cASC), i, 1) = "0" Then
            F = fino
        Else
            F = largo
        End If


        pdf.rect xpos, p201, F, p11, "F"
        xpos = xpos + F
        If Mid(BarCodes(cASC), i + 1, 1) = "0" Then
            xpos = xpos + fino
        Else
            xpos = xpos + largo
        End If

    Next
Next
pdf.Text "30","235",xpos

pdf.rect xpos, p201, largo, p11, "F"
xpos = xpos + fino + largo
pdf.rect xpos, p201, fino, p11, "F"


end Sub
    
asked by anonymous 07.09.2015 / 02:23

3 answers

2

In standard 2 of 5 the number is required. So the function puts another zero

    
23.04.2016 / 04:37
-1
Sub fbarcode(valor_barras,xPos,p201)
    Dim f, f1, f2, i
    Dim texto
  Dim p11
  p11=12  'Altura do codigo de barras
    Const fino = 0.3
    Const largo = 0.6
    Dim BarCodes(99)
    if isempty(BarCodes(0)) then
        BarCodes(0) = "00110"
        BarCodes(1) = "10001"
        BarCodes(2) = "01001"
        BarCodes(3) = "11000"
        BarCodes(4) = "00101"
        BarCodes(5) = "10100"
        BarCodes(6) = "01100"
        BarCodes(7) = "00011"
        BarCodes(8) = "10010"
        BarCodes(9) = "01010"
        for f1 = 9 to 0 step -1
            for f2 = 9 to 0 Step -1
                f = f1 * 10 + f2
                texto = ""
                for i = 1 To 5
                    texto = texto & mid(BarCodes(f1), i, 1) + mid(BarCodes(f2), i, 1)
                next
                BarCodes(f) = texto
            next
        next
    end if

    'xPos=14
    'p201=233
    pdf.rect xPos, p201, fino, p11, "F"
    xPos = xPos + fino + fino
    pdf.rect xPos, p201, fino, p11, "F"
    xpos = xpos + fino + fino
    For n = 1 To Len(valor_barras) Step 2
        cASC = cint(Mid(valor_barras, n, 2))
        For i = 1 To 10 Step 2
            If Mid(BarCodes(cASC), i, 1) = "0" Then
                F = fino
            Else
                F = largo
            End If
            pdf.rect xpos, p201, F, p11, "F"
            xpos = xpos + F
            If Mid(BarCodes(cASC), i + 1, 1) = "0" Then
                xpos = xpos + fino
            Else
                xpos = xpos + largo
            End If
        Next
    Next

    pdf.rect xpos, p201, largo, p11, "F"
    xpos = xpos + fino + largo
    pdf.rect xpos, p201, fino, p11, "F"

end Sub

Function call:

Set pdf=CreateJsObject("FPDF")
pdf.CreatePDF()
pdf.SetPath("fpdf/")
pdf.LoadExtension("Codabar")
pdf.SetSubject("Results")
pdf.SetTitle("Results")
pdf.SetLeftMargin(35)
pdf.SetAutoPageBreak( 0)
pdf.Open()
---> fbarcode nome,Linha,coluna+2

pdf.close() 
filewrite=Server.MapPath("path/arq.pdf")
pdf.Output(filewrite)
    
23.04.2016 / 04:33
-1

<%
Sub fbarcode(valor_barras,xPos,p201)
    Dim f, f1, f2, i
    Dim texto
  Dim p11
  p11=12  'Altura do codigo de barras
    Const fino = 0.3
    Const largo = 0.6
    Dim BarCodes(99)
    if isempty(BarCodes(0)) then
        BarCodes(0) = "00110"
        BarCodes(1) = "10001"
        BarCodes(2) = "01001"
        BarCodes(3) = "11000"
        BarCodes(4) = "00101"
        BarCodes(5) = "10100"
        BarCodes(6) = "01100"
        BarCodes(7) = "00011"
        BarCodes(8) = "10010"
        BarCodes(9) = "01010"
        for f1 = 9 to 0 step -1
            for f2 = 9 to 0 Step -1
                f = f1 * 10 + f2
                texto = ""
                for i = 1 To 5
                    texto = texto & mid(BarCodes(f1), i, 1) + mid(BarCodes(f2), i, 1)
                next
                BarCodes(f) = texto
            next
        next
    end if

    'xPos=14
    'p201=233
    pdf.rect xPos, p201, fino, p11, "F"
    xPos = xPos + fino + fino
    pdf.rect xPos, p201, fino, p11, "F"
    xpos = xpos + fino + fino
    For n = 1 To Len(valor_barras) Step 2
        cASC = cint(Mid(valor_barras, n, 2))
        For i = 1 To 10 Step 2
            If Mid(BarCodes(cASC), i, 1) = "0" Then
                F = fino
            Else
                F = largo
            End If
            pdf.rect xpos, p201, F, p11, "F"
            xpos = xpos + F
            If Mid(BarCodes(cASC), i + 1, 1) = "0" Then
                xpos = xpos + fino
            Else
                xpos = xpos + largo
            End If
        Next
    Next

    pdf.rect xpos, p201, largo, p11, "F"
    xpos = xpos + fino + largo
    pdf.rect xpos, p201, fino, p11, "F"

end Sub
//chamada da função 
fbarcode nome,H,V+2     
    
23.04.2016 / 04:42