0

I need to create an vbo action to produce a document (pdf) with a page for every item selected in the list.

Using im using hook_action_info but the callback get called once for every item selected; I need to have a function that get called with the list of selected items.

I've seen the Pass ids as arguments to a page action, that can fit my needs, but hey I'll love to avoid having such kind of urls (if possible, of course)

Is possible?

1

First, I need to point out that what you are trying to do is not a smart use of VBO. VBO is usually used with single-off tasks like publishing a single node or sending an email.

In your worker function (key of your hook_action_info() return array), you can receive an extra argument that has meta information of the current running task and total number of tasks.

You can however do some ninja work to set another batch work and append the generate PDF function there but it's difficult to do in most cases.

| improve this answer | |
2

You don't do it at once, you generate the document page by page (item by item). The document gets created on first run, and on the last run you do whatever cleanup you need.

See archive.action.inc that ships with VBO for an example of this approach.

You can mark your action as "aggregate", and get all rows, but that's going to significantly limit the number of items you can add to the document (depending on your memory limit). VBO is designed to work item-by-item.

| improve this answer | |
  • On every run, i can check if the html file exists or not and then append the data, but i need on the last run to invoke the pdf converter (wkhtmltopdf). Anyway, this looks to me as a trick, and not a solution.. – Strae Oct 2 '12 at 14:10
  • 1
    That's perfectly fine. The archive action does stuff on the last run as well. This is how VBO is supposed to work. Item by item. Otherwise you run out of resources. – Bojan Zivanovic Oct 2 '12 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.