Printing barcode with wpdf. Need help.

  • I need to print a barcode (EAN13) into PDF canvas, using of course WPDF

    I have a component (named Tean) that allows to generate a barcode and draw it into a bitmap (i use a 1 bit depth bitmap, b/w).

    So now i need to draw this bitmap into the WPDF canvas

    Problem: The barcode so printed can't be read by a barcode reader.

    Seems to me that the problem is that the barcode bitmap is stretched for the dimensions that are selected in my pdf designer.

    Now i do:

    rect.left:=round(leftcoord*pdfresolution);
    rect.top:=round(topcoord*pdfresolution);
    rect.right:=round((leftcoord+barcodewidth)*pdfresolution);
    rect.bottom:=round((topcoord+barcodeheight)*pdfresolution);

    wpdf.drawbitmap(rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,bmp.handle)

    // leftcoord,topcoord,barcodewidth and barcodeheight are set in my page designer


    What i want is that the barcodewidth is calculated automatically so the barcode is printed with a perfect ratio (i think this is the problem why now it's not read correctly by the barcode reader)

    I have tryed to do: barcodewidth:=bmp.width/wPDF.XPixelsPerInch
    but the barcode so printed is very small

    Any help ?

    thank you in advance

    Roberto