It effectively creates a new document that contains a primary text frame and creates a table based on two fields from the UI, none of which are relevant to the issue. It then opens an export PDF location dialog box, and when a folder is chosen, it bases the filename on input from the UI at the start of the script, and then closes the ID file without saving.
The script works fine... provided that the manifest is one page long. However, there will be instances where the manifest may be several pages long.
In instances where the table is longer than one page, the script runs fine until the prompt asks to save the PDF, the ID file in the background is one page long and has an overset text icon. If I remove the export and file close lines, the script successfully generates a multi-page document.
I've tried using $.sleep between the last text formatting function and the export instruction, but it just idles for a the appropriate time and the outcome is the same... 1 page with overset text. I've tried making an if overset text... $.sleep, but again the outcome is the same.
The script is long and boring but for those interested, it can be found here: https://dl.dropboxusercontent.com/u/55743036/HPSmanifest.jsx
Is there some kind of bug here, or am I missing something? I read the following thread How do I "shift-place" text? and I'm sure my answer lies in here, but the primary text frame/smart text reflow solution should work... right?
$.sleep will hang indesign so it's helpless in your case.
A quick fix could be to work in two times. As it seems your script works fine without export. You can have a main routine calling for two sub routines. The first one will do all but PDF then close file. The second reopens and do export then close it again. I know it's cumbersome but it could avoir your issues.