The organization I run openchurch for, uses the bulletin feature, but unfortunately, they have two pdf files, "inside" and "outside". I have found a solution to merge them into one pdf file, but I am not sure how to implement it into the add bulletin content node. i would need 2 file upload forms on the node, and also need help making drupal process this code with the uploaded pdf files. if i can at the very least get pointed in the right direction (what features i need to use, etc) i would appreciate it greatly.

code:
http://www.johnboy.com/blog/merge-multiple-pdf-files-with-php

Comments

www.deweducation.com’s picture

nice

linwiz’s picture

I have created a second upload field on the node creation form, and have tried to create a "Rule" for creating new content.
the code below is never executed. i have working php code, i just need to figure out how to make drupal use it.

here is the Rule i am now working with:

UPDATED:

{ "rules_merge_pdf" : {
    "LABEL" : "merge pdf",
    "PLUGIN" : "reaction rule",
    "TAGS" : [ "merge" ],
    "REQUIRES" : [ "rules", "php" ],
    "ON" : [ "node_insert" ],
    "IF" : [
      { "node_is_of_type" : {
          "node" : [ "node" ],
          "type" : { "value" : { "openchurch_bulletin" : "openchurch_bulletin" } }
        }
      }
    ],
    "DO" : [
      { "php_eval" : { "code" : "watchdog(\u0027debug\u0027, $node[node:field-oc-bulletin-file][\u0027file\u0027].\u0022 \u0022.$node[node:field-oc-bulletin-file2][\u0027file\u0027].\u0022 \u0022.$node[node:field-oc-bulletin-date]);\u000D\u000A$uploaddir = \u0022sites\u002Fdefault\u002Ffiles\u002Fbulletins\u002F\u0022;\u000D\u000A    $command = \u0022\u0022;      \u000D\u000A    $output = $uploaddir.\u0022Bulletin_\u0022.$node[node:field-oc-bulletin-date].\u0022.pdf\u0022; \u002F\u002Fset name of output file \u000D\u000A    $command = \u0022\u002Fusr\u002Fbin\u002Fpdftk $node[node:field-oc-bulletin-file][\u0027file\u0027].\u0022 \u0022.$node[node:field-oc-bulletin-file2][\u0027file\u0027] output $output\u0022; \u000D\u000A    passthru($command); \u002F\u002Frun the command \u000D\u000A    echo $output;" } }
    ]
  }
}
drupalninja99’s picture

Category: support » feature
Status: Active » Needs work

This is a strange request outside of the scope of OpenChurch. If you have multiple PDF files, why not just update the field to support multiple files?

/admin/structure/types/manage/openchurch-bulletin/fields/field_oc_bulletin_file

That is what I would do, as it's much simpler.

drupalninja99’s picture

Status: Needs work » Closed (works as designed)