VBO custom action: get the list of selected items
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.