I can see that Rules has an action made available to it called "Saved PDF as file on server" but there doesn't seem to be an appropriate event ( by default or provided by Views PDF ) to attach the action to, although without any specific pointers I admit I don't know exactly what I'm looking for.

What should I be looking for or doing ?

Thanks

El B

Comments

El Bandito’s picture

After exhaustive trawling I'm fairly certain that nobody has provided any docs or clues about how to achieve this.

I am tempted to think the solution is to create a module which registers an event itself and then hooks into the Views rendering process at "hook_views_pre_render" in order to fire the event. What makes me question this is that I don't understand why the Views PDF module doesn't provide such an event itself ?

El Bandito’s picture

Status: Active » Closed (fixed)

Finally got this working. I will document how when I have also mastered sending the PDFs by email.

My fundamental problem was one of perspective. I was expecting to invoke my View to generate a PDF and then somehow fire an event and invoke the action provided by the module. In fact the action invokes the View itself and builds the PDF itself so all you actually have to do is register an event with Rules ( hook_rules_event_info ) and invoke the event at some appropriate point. In my case made a little more complicated by needing to pass an argument from the event through to the action which would then use it as an argument for the View.

j4’s picture

Hi,

I need to print pdf of node when node is created and also create a rule to send this pdf as an attachment to the user who created the node. Can you help me as your needs seem similar?

Thanks
jaya

star-szr’s picture

Here's an example setup to generate one PDF per node:

  1. Add an argument to your view, I used Node: Nid for this example.
  2. Add a new triggered rule (admin/rules/trigger/add)
  3. Set Event to Node > After updating existing content or Node > After saving new content
  4. Add any necessary conditions (i.e. restrict to certain content types)
  5. Add a rule Views PDF > Save PDF as file on server
  6. Set the View dropdown to your view.
  7. Set Arguments to [node:nid]
  8. Set absolute path (i.e. NOT /sites/default/files, you'll need the full path on disk) and use tokens to build the filename.
  9. Save an existing node or create a new node (depending what you chose in #3) and you should get a PDF generated assuming all your permissions etc. are correct.
alibama’s picture

@Cottser - thanks = your recipe got me started for doing the process with Views Bulk Operations = http://blog.hsl.virginia.edu/drupalpress/views-pdf-vbo-rule-sets-thousan...

great work & thanks to the upkeepers :)

deejmer’s picture

Issue summary: View changes

I know this thread is heavily aged, but @cottser's example is great. I'm missing one last piece though - how could one then attach the rendered PDF back to the node its referencing in a file field?