barcode printing is too long

I am new in Xojo.
I am working with Barcode printing using code given below.
what I need is How to Scale Barcode?

dim z as new BarcodeGeneratorMBS
   z.Symbology = type
  z.Encode text
  dim r as ZintRenderMBS = z.Render
  const factor = 1.5
   dim px as Double = 200
  dim py as Double = 40//pic.Height 
    call pdf.SetFillColor 0
  call pdf.SetStrokeColor 0
  dim lines()    as ZintRenderLineMBS = r.lines
  dim hexagons() as ZintRenderHexagonMBS = r.hexagons
  dim rings()    as ZintRenderRingMBS = r.rings
  dim strings()  as ZintRenderStringMBS = r.strings
   if UBound(strings)>=0 then
    for each s as ZintRenderStringMBS in strings
      dim x as Double = s.x*factor + px
      dim y as Double = s.y*factor + py
      dim f as Double = s.FontSize * factor * 0.7
       call pdf.SetFont("Helvetica", pdf.kfsCondensed, f)
      dim textLen as Double = pdf.GetTextWidth(s.Text)
       x = x - textLen/2.0
      y = y - f * 0.4
        call pdf.WriteText(x,y,s.Text)
  end if
    if UBound(rings)>=0 then
  end if
   if UBound(lines)>=0 then
    for each line as ZintRenderLineMBS in lines
      dim x as Double = line.x*factor + px
      dim y as Double = line.y*factor + py
      dim w as Double = line.Width *factor + 0.1 
      dim h as Double = line.Length*factor + 0.1
      call pdf.Rectangle(x, y, w, h, pdf.kfmFill)
  end if
   if UBound(hexagons)>=0 then
  end if

My barcode String is 17-digits long . After print report barcode is too long more than half of A4 size paper width.

I want to make barcode with smaller width .

reduce factor?
and px/py coordinates?

I have made changes like below

  const factor = 1.0
    dim px as Double = 200
  dim py as Double = 30

barcode width has changed and lines get merged so now it doesn’t scanned

Maybe you remove the +0.1 from the code used for width and height?

Please try to understand code and debug it to make it work.
I can only guess from here

When you print, check the print quality.
IF you reduce the size but print at 72dpi, the lines will blur.
Set the highest dpi you can… at least 300 dpi
That way the thin lines will be distinct.

Be aware of the thickness of any outlines for the rectangles… (strokewidth)
if the outlines remain thick , when you go to smaller sizes, you wont see any gaps.