An even easier solution is to use the line markup annotation.
this.addAnnot({type:"Line", page:0, points:[....]});
There are all kinds of graphical annotations. Keep in mind these are not part of the PDF page content.
Read this:
https://www.pdfscripting.com/public/PDF-Page-Coordinates.cfm?sd=40
If this will be performed from a privileged script, then there are more possibilities for new document create with JavaScript. For example flattening will push anntation and field appearances into the PDF content. And there is the Report Object, which has the ability to create horizontal lines.