Create the pdf version of a node programatically (and attaching that pdf version to that node) I have installed the print module. Every time I create a node of type X a print version can be generated each time I click the print link.

The thing is that I need that pdf to be generated programatically, and not by hand every time I click on the link.

I need (I´ve tried with rules module, without any success) to create the pdf version of that specific nodetype X, and attach that pdf version to the node that is being created.... without me clicking to the print link, downloading the file, editing the node and then attaching that file to it.

Is there a way to do that?

Thanks for your insight!!!

Rosamunda
You can could start by taking a look at the PHP PDF extension and see how that works out for you. If it does, then you can implement a hook_node_save() - assuming you are in D7, and every time that a node is saved, call your custom PDF functions to generate the PDF.

After your PHP PDF implementation creates the PDF file, you should use Drupal's File API to place the file in the proper place. You would use the File API because it creates an entry in Drupal's file table, and it automatically handles permissions for you - so you can for example, support both public and private (session-protected) files.

Once you upload the file to your web server with the File API, you can then use the Field API to put a reference to the newly created PDF file in one of your node's custom fields. The node's custom field would be of type "file field", and what you would save to that field programatically is the newly created file's fid. The Field API will provide you with the fid.

Finally, you will need to implement a theming function that accepts the node id as a parameter, loads the node in question, looks for the custom field holding the file (using again the Field API), turns the fid inside that custom field into a link with the proper access-level (using the File API), and returns the themed link to your theming layer so it can be printed with the page, and clicked with the users.

In conclusion, unless somebody suggests a contrib module that does this, you would end up implementing at least two Drupal APIs, one external PHP API, and creating some theme hooks. If you are an experienced developer, it should take at least a few hours (or a pair of days).