Document Merge

rlp - November 4, 2009 - 14:08

I have limited Drupal experience.

I'm considering setting up my internal project management, using a module such as storm.

I want to use the information from the nodes I create to automagically create documents for printing (such as letters, invoices, forms etc). I can't find an appropriate module for doing this, although I can see that the token module would do the replacement. How could I use this to produce documents (say in RTF format). Or is there a different, more appropriate module that I should be looking at?

I'm thinking I could have one node called 'templates' that would have my precedent documents attached. I would then want to be able to select a precedent for a certain person/organisation/project (or any other node) and fill in any relevant tokens.

Can anyone point me in the right direction please?

Many thanks,
Richard

_

WorldFallz - November 4, 2009 - 14:58

You might checkout the http://drupal.org/project/print module.

_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.

Thanks WorldFallz -- I'll

rlp - November 4, 2009 - 16:27

Thanks WorldFallz -- I'll check that out.

Again thanks Worldfallz for

rlp - November 6, 2009 - 14:10

Again thanks Worldfallz for coming back to me quickly.

This isn't quite what I want: I'd like to be able to upload precedent documents (perhaps a node called 'templates') which I could then merge from data in other nodes (e.g. client data). It appears to me that for a user to change a precedent letter using the Print module, they would have to edit the php template file supplied by the module.

Perhaps I'm going to have to learn module development if I want to be able to achieve my objectives?

Anyone else got any thoughts?

Many thanks,
Richard

_

WorldFallz - November 6, 2009 - 14:28

Do you mean you need to take content from existing documents (ie word docs) and merge it with node data and then print? If so, I think you will definitely need to code that. ms office produces notoriously ugly and bloated xml which is very difficult to deal with. I don't know of any module handles importing of content from office docs with the exception of http://drupal.org/project/fileframework which actually uses open office. Might be worth a look.

That will be the most difficult part. Then, once you solve that, you should be able to easily create a node that merges data from different locations to print with the print module.

_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.

Thanks again for your timely

rlp - November 6, 2009 - 15:56

Thanks again for your timely response.

Your description of what I want to do is pretty accurate, except that I want to write the templates as nodes (so I didn't have to deal with the ugly ms bloat). I was hoping that I could have a node called "precedent", the body of which would be a letter (or other document), which included a bunch of tags (tokens). I could create new precedents simply by creating the relevant nodes and I could edit current precedents whenever I needed to make changes.

I could then have a form where I chose a client, chose a precedent letter, and it merges the data together to produce a letter that I could print. The end result could be a simple HTML page, as long as I could print it OK, or else a PDF or whatever. To do the merging, I could simply use the tokens already provided in Token (e.g. "%field_stuff").

I believe what I want is a simple case of "document automation" or "document assembly". I'm a lawyer, and want to use Drupal for my case management, but some kind of simple document automation is a prerequisite for that.

Thank you for helping me to put into words what I want... I'm still thinking this isn't out there yet for Drupal though.

Rich

_

WorldFallz - November 6, 2009 - 16:08

ahh... very interesting use case. Using nodes for the templates makes this a whole lot easier. To distill it a bit further, basically you want to take info from one node of type precedent, add some client info (clients are actual registered site users or simply another node type?), and combine it into a separate content type. Actually, this is for the most part fairly easy to do believe it or not-- the sticking point will be what the body of the precedent is-- text is simple, 'documents' are not.

I would approach this by using nodereferences and optionally, userreferences (if the clients are actual users). In the merge content type you would select the nodereference for the precedent and the client, then you could just theme the node type or use a view to pull the appropriate info into the merged node that just gets printed with the print module. Its actually much hard to explain than it is to do, but it should definitely be doable (with the exception of processing 'documents' instead of text).

_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.

Ah, your reply makes me much

rlp - November 6, 2009 - 16:33

Ah, your reply makes me much more hopeful.

Clients would be another node type, rather than a user.

The body of the precedents node would be simply text--so that sounds much better. If you can use html in the body, then you can do everything that I would need to do in a letter (new lines, bold, italics, a table).

I would approach this by using nodereferences and optionally, userreferences (if the clients are actual users)

Does that mean I would create a new content type and use a node reference under CCK (or a user reference).

I was thinking that users probably wouldn't be clients, users would be the different lawyers and support staff working the cases.

In the merge content type you would select the nodereference for the precedent and the client, then you could just theme the node type or use a view to pull the appropriate info into the merged node that just gets printed with the print module.

OK, so can I set out a to do list for myself and tell me if I'm getting it right:

1. Create a CCK node called Client with lots of details (create a few example clients)
2. Create a CCK node called Precedent whose body is the proposed text for a letter (create a few example letters, including tags referring to client fields)
3. Create a CCK node called Document, which has a node reference to a client and a node reference to a precedent.
4. Create a view that gets the body of the Document node and translates all the tokens, including the tokens from the nodes that the Document refers to. (This is the bit I'm not sure about--I've only really used Views in the past to create pretty tables and lists, I hadn't realised you could thoroughly customize how a node is displayed...)
5. Install the Print module and make the Document node so that it can be printed without all the drupal gumph (menus etc).

Am I getting it?

_

WorldFallz - November 6, 2009 - 16:47

Yep-- you've got the general idea. Step 4 is where you have several different options. I believe the print module supports views-- if it does, you can simply create a view that pulls together all the different pieces of the nodereferences to the precedent and client nodes into a single place. You'll need to add what views calls 'relationships' to be able to reference the individual fields in each of referenced nodes-- it sounds harder then it is. See http://gotdrupal.com/videos/drupal-views-relationships for how to use views relationships.

If print module doesn't support views, then you need to just theme your document node to display the different pieces of information from the referenced nodes upon viewing the page. You can theme nodes manually or use the contemplate module.

_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.

Thank you very much for your

rlp - November 6, 2009 - 16:55

Thank you very much for your invaluable help. I'll endeavour to 'pay it forwards...'

Best wishes,
Richard

_

WorldFallz - November 6, 2009 - 16:59

Good luck ;-)

_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.

 
 

Drupal is a registered trademark of Dries Buytaert.