Usually you add the barcode using LiveCycle Designer.
If you want to add it automatically, I would look into techniques where you add an extra page, that already has a barcode, to your document. You can use Assembler to do that.
We can't just add a barcode object to a PDF with code.
Jasmin