files increase in size as JScript saveAs loops through
Situation: I'm using JavaScript to feed rows from a CSV file into a PDF and save one PDF for each row.
Problem: Subsequent files are larger in size though there is not an increase in the amount of information. For example, the first file is 123KB. The 500th file is 5.03MB. The PDF is still only 3 pages, and there is less information in the 500th PDF than the first.
What I've tried: Nothing. I haven't tried anything else because it is still in the process of creating the files as I write this forum post.
Potential solution: Is there a parameter for the saveAs function that will save the PDF as a compressed PDF?
Possibly important details: The PDF is form IRS 1095-C. It is a three page form. People who don't need the third page (it's an overflow page) can have the form with just two pages. During the process, I'm looking at the row in the CSV file and deleting the third page if it's not needed. After I save the file with two pages, I add that third page back. If three pages were necessary, then the third page is not deleted. I did notice that when the files are going through, there is a notification on the bottom of the page that it is importing/consolidating fonts. That's the only thing that I see that might be different between files. When I look at individual files, they're all 2-3 pages, and there's nothing extra that I can find.