This worked for me:
add_library('pdf')
pdf = beginRecord(PDF, 'simple.pdf')
for index in range(1,10):
background(100)
stroke(255)
line(5,5, index * .5, height-index)
if index < 9:
pdf.nextPage()
endRecord()
I added that if statement to avoid a blank page. Maybe there’s a better solution.