Jump to:
| Project: | Fill PDF |
| Version: | 7.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
| Issue tags: | rules integration |
Issue Summary
Goal: Provide more flexibility to third-party modules and site builders to both trigger Fill PDF programmatically and to react to Fill PDF being triggered and modify the data in the PDF and potentially perform other actions.
Rules works by defining Events, Conditions, and Actions. Data types also need to be provided, and it's capable of intelligent saving.
Data type
Fill PDF fields (simply fillpdf if a machine name is required. Should contain the Fill PDF fields in a sensible state, according to the event, indexed by PDF key. Intelligent saving should work in the sense that several Rules actions should be able to work together. Nothing is actually saved, so I'm not sure if it's relevant. However, the data should be alterable when responding to actions where this makes sense.
Events
Fill PDF is about to prepare PDF-filling data
fillpdf_merge_pdf() has been called, but tokens have not yet been replaced. Changes can be made to processing behavior at this stage; for example, flatten or download could be changed.
Fill PDF is ready to fill the PDF
Tokens have now been replaced, and $fillpdf contains the replaced values. They can be modified prior to being merged into the PDF.
Fill PDF has filled the PDF
The PDF has been filled, and the file contents are available. This event is most likely to be used when trying to send the PDF as an attachment.
Conditions
None I can think of. All necessary data will be provided in the $fillpdf data array, including metadata such as URL arguments. Rules's built-in conditions should be able to provide a great deal of flexibility from there.
Actions
Fill a PDF
This would be like going to a Fill PDF link, but the work would be done programmatically via Rules. This action would create a variable with the contents of the filled PDF.
Send PDF to user's browser
Would require a variable created with the previous action. Does what the name says.
Save PDF to a file
Like the prior action, but saving to a file. The file path could be overridden; otherwise, metadata in the configured variable would be used to discover the path. The file would be placed in file_prefix://fillpdf if none was set.
Perform the default action on the PDF
This would behave like going to the Fill PDF link and do whatever was configured, downloading or saving to a path (if configured).
Default rules
I intend to have a default rule to enable sending a filled PDF as an e-mail attachment. That's pretty much what prompted Rules integration.
Original post by landing:
Would it be possible to integrate this module with Rules. I would like to fill a pdf template with node values once a node is created.
Comments
#1
It'd be with Rules, not Actions, but yes, this is a good idea. It won't necessarily happen in short order, although patches to get it started are welcome. Rules are quite easy to implement - start at http://drupal.org/node/878718 - and the function you'd want to wrap or call is most likely fillpdf_merge_pdf().
#2
New features happen in 7.x first now.
#3
Changing the title to what this really is.
#4
OK, so I'm going to try implementing this. Here is the spec I'll work against:
Goal: Provide more flexibility to third-party modules and site builders to both trigger Fill PDF programmatically and to react to Fill PDF being triggered and modify the data in the PDF and potentially perform other actions.
Rules works by defining Events, Conditions, and Actions. Data types also need to be provided, and it's capable of intelligent saving.
Data type
Fill PDF fields (simply fillpdf if a machine name is required. Should contain the Fill PDF fields in a sensible state, according to the event, indexed by PDF key. Intelligent saving should work in the sense that several Rules actions should be able to work together. Nothing is actually saved, so I'm not sure if it's relevant. However, the data should be alterable when responding to actions where this makes sense.
Events
Fill PDF is about to prepare PDF-filling data
fillpdf_merge_pdf()has been called, but tokens have not yet been replaced. Changes can be made to processing behavior at this stage; for example,flattenordownloadcould be changed.Fill PDF is ready to fill the PDF
Tokens have now been replaced, and
$fillpdfcontains the replaced values. They can be modified prior to being merged into the PDF.Fill PDF has filled the PDF
The PDF has been filled, and the file contents are available. This event is most likely to be used when trying to send the PDF as an attachment.
Conditions
None I can think of. All necessary data will be provided in the
$fillpdfdata array, including metadata such as URL arguments. Rules's built-in conditions should be able to provide a great deal of flexibility from there.Actions
Fill a PDF
This would be like going to a Fill PDF link, but the work would be done programmatically via Rules. This action would create a variable with the contents of the filled PDF.
Send PDF to user's browser
Would require a variable created with the previous action. Does what the name says.
Save PDF to a file
Like the prior action, but saving to a file. The file path could be overridden; otherwise, metadata in the configured variable would be used to discover the path. The file would be placed in file_prefix://fillpdf if none was set.
Perform the default action on the PDF
This would behave like going to the Fill PDF link and do whatever was configured, downloading or saving to a path (if configured).
Default rules
I intend to have a default rule to enable sending a filled PDF as an e-mail attachment. That's pretty much what prompted Rules integration.
There are likely incorrect assumptions in this spec, but it is a conceptual start. I'm going to copy it to the issue summary and will update that as the work goes on.