Views PDF, VBO + Rule Sets = thousands of custom forms

Note to all:  this module is majorly messed up – am leaving this warning here until http://drupal.org/node/1494820 is resolved – briefly the template files get deleted and the output becomes munged after ~1,000 pdfs are generated.   Also while some of my early tests were cranking ~100-200 pdfs per minute we’re seeing results now in the 3-5 per minute making this module unusable for large scale projects. here’s a patched version for D6views_pdf-patched

Views PDF allows you to output the results of a view onto a PDF. You can even upload an existing PDF to use a background template – pretty cool.   For the Audio Visually inclined here’s your 3 minutes of fun. http://www.youtube.com/watch?v=PszjYSq7xQQ

Use Case: Generate 40,000 PDF’s with a user’s name on them and some other predefined fields and make these files accessible to the user for download. 

Problem: creating the PDF’s on the fly is slow – so we need to have them all pre-generated

Solution: Used Cottser‘s writeup here http://drupal.org/node/1415380#comment-5701968 and modified it to be a rule set instead of a rule – with argument type node. Under that added one rule that ended up looking like this

Rule set for saving PDF's to server

Rule set for saving PDF's to server

As you can see the rule requires a pdf view – so hopefully you’ve already got one of them here are some shots of mine

PDF View

PDF View

and here are

views pdf argument settings

views pdf argument settings

the argument settings.  Now earlier we mentioned that the pdf needs to be accessible to users, so back over in our rule set we take an action – we load a referenced user (the user is referenced in the node itself through a user reference cck field) so our final rule set ends up looking like this

Final look of Rule Set

Final look of Rule Set

Ok – almost finished.  Now that we have a rule set we need to add this to a views bulk operation view so that we can “do the deed.”

I like Improved Admin because it gives you a nice starting point for working with Views Bulk Operations.. use whatever brings you the greatest joy.

PDF Save Rule Set in Views Bulk Operations

PDF Save Rule Set in Views Bulk Operations

Once your Rule Set is added to your VBO you may use it with any set of nodes you like.  On our VMWare machine we were churning ~200 pdfs per minute, not too shabby.

This entry was posted in Planet_Drupal and tagged , , , , , , . Bookmark the permalink.

7 Responses to Views PDF, VBO + Rule Sets = thousands of custom forms

  1. Pingback: Drupal 6 + Modules we Love Volume 1, Views | Wordpress VS Drupal

  2. Nicolas says:

    Hi,
    thx for your article !

    I had the same problem (in D7), you could check
    http://drupal.org/node/1494820#comment-5809560
    and http://drupal.org/node/1230098 the correction sould’nt be too difficult to do in D6 too.

    • alibama says:

      awesome, that’s great news = wish I had seen it a few days ago! I’ve patched D6 and will add the file to the top of the post until fixed.. thanks again!

  3. alibama says:

    how to add labels? haven’t tested this in the unformatted pdf version… in the table formatted version it’s pretty clear – you might try the “php before render” settings?

  4. Gerald Mengisen says:

    Thanks so much for posting this; it’s exactly what I needed. One hint: although it says in the action that one should use an absolute path as destination path for the files, it seems that just “files/xxx” works as well – one headache less when moving the rule from dev to production (I’m using Drupal 6 for the moment).

  5. Pri says:

    Hi, alibama.
    How to implement that setting for Drupal 7?