We are attempting to use FillPDF for an elementary school and so far so good. parents and teachers use Drupal7 to capture the data, primarily in the Student node and associated fields.

The problem arises when the school needs to print a pdf form. Currently they have to push a print button for each and every individual student, so if there are 50 students (nodes) in a grade, they have to sit there and push the button 50 times.

The request is to be able to press one button and have the entire set (say 50, as in the above example) process and create the pdf(s). For illustration, I will stick with a scenario of 50 student nodes: There are several approaches possible:

  1. create a single PDF file, with 50 pages - in this case a form page for each student, as in page 1 through 50;
  2. have it create 50 independent pdf files, but have these downloaded in background;
  3. don't create the PDFs, but instead have the resulting aggregated fdf file downloaded for processing by the pdf itself, where the one .fdf file would contain all 50 students.

The immediate problem I need help on is that I have an array of nodes to process (the 50 student nids). I developed a simple PHP program to feed these nids, one at a time, to the main function in fillpdf.module: fillpdf_merge_pdf() It prints the first node perfectly, but then stops. I tested the processing of the array and that is working so my thinking is that the last few statements in fillpdf_merge_pdf(), where it sets up the HTTP headers and then executes a drupal_exit() is stoping control coming back to my loop; that is, drupal exits at that point.

Here is the strange but potentially good thing: If I delete that last line in the fillpdf_merge_pdf() function (drupal_exit()) my loop process continues, and I get back a single PDF with all of the students in it; unfortunately, the pdf is malformed (seemingly the last 100 or so bytes for EOF are missing). Yet the document seems to contain all of the students.

A key issue needed to make progress on helping the school is, does anyone know a way that I can use fillpdf functions in a loop process so I can just feed it programmatically, one node id at a time?

Comments

wizonesolutions’s picture

Hey Ron,

I see you are on 7.x, which I believe doesn't have the ability to save to file yet. However, this ability is well-documented in the issue for it - search the 6.x issues. If you can fix up that patch to apply to 7.x (or well, re-implement the functionality) and you provide me with a working patch in that issue, I will test and commit it. During the development of that functionality, I added an extra parameter to fillpdf_merge_pdf() to not generate the download. That's what you are in need of.

It is good to hear you've gotten close. If you get stuck still let me know. I have been rather busy, so I wanted to give you actionable next steps. The backup plan is to wait for me :)

wizonesolutions’s picture

Status: Active » Closed (won't fix)

The ability to save to file has now been committed, so closing this.