I need to create an vbo action to produce a seperate document (pdf) of every selected node's detail page (node--content.tpl.php).

What i have to do for that..??

Right now i am creating simple pdf with dummy variables to check pdf is generate or not,

For that i done the following code

function MYMODULE_action_info() {
    return array(
        'export_pdf_bulk' => array(
        'type' => 'entity', 
        'label' => t('Export PDF'),
        'configurable' => FALSE, 
        'behavior' => array('view_property'),
        'triggers' => array('any'),   

function export_pdf_bulk(&$entity, $context) {

$html = '<html><body>';
$html.="<div class='test' id='test_print'>";
$html.="<p align='center'><b>Testing</b></p>";
$html.="<p>Dear Sir/Madam,</p>";
$html.="<p>Testing string Here</p>";
$html.="<p>Details are as follows:</p>";
$html .= '</body></html>';

pdf_using_mpdf_api($html, "Track grievances");

Using this code to generate dummy pdf (Use MPDF for generate pdf https://www.drupal.org/project/pdf_using_mpdf) for selected content, i got the ajax error and in error pdf content is displayed in junk characters, but ajax code is 200 and status is ok, then why pdf is now downloading and display in ajax error in junk characters??


You can achieve this using rules. Import following component & add Rule component in Views bulk operation list as shown in figure below:

{ "rules_create_pdf" : {
    "LABEL" : "Create PDF",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "REQUIRES" : [ "php", "rules" ],
    "USES VARIABLES" : { "node" : { "label" : "Node", "type" : "node" } },
    "ACTION SET" : [
      { "php_eval" : { "code" : "$view = node_view($node, \u0027PDF\u0027);\r\n$html = drupal_render($view);\r\npdf_using_mpdf_library_exist();\r\n_pdf_using_mpdf_generator($html, \u0027node-\u0027.$node-\u003Enid);" } }

In order to save PDF files at server use above Rule component & comment two line given below in pdf_using_mpdf.module of function _pdf_using_mpdf_generator. You can find that on line no. 324 & 325 of pdf_using_mpdf 7.x-2.6.



enter image description here

|improve this answer|||||
  • i can't able to see any figure in Your Answer – Sanjay Mar 12 '15 at 8:31
  • Its image with text "SELECTED BULK OPERATIONS" in blue color – Vishal Patil Mar 12 '15 at 8:32
  • it still display me the junk characters as ajax error, same as before.. nothing changed – Sanjay Mar 12 '15 at 9:34
  • it display An ajax error occurred, continue to error.. on click on continue to error i got this message "An error occurred while processing views_bulk_operations_active_queue_process with arguments: views_bulk_operations_active_queue_process" – Sanjay Mar 12 '15 at 9:40
  • Hi @Sanjay, if you are saving nodes on server then check updated answer. – Vishal Patil Mar 12 '15 at 11:09

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.