Im using PDF Using MPDF module to generate 4 files when a node is saved using its API function pdf_using_mpdf_api
:
function MYMODULE_node_insert($node){ // PDF generation : // Generate standard version $view = node_view($node, 'PDF'); $html = drupal_render($view); pdf_using_mpdf_api($html, 'reference_'.$node->nid); // Generate short version $view = node_view($node, 'pdf_short'); $html = drupal_render($view); pdf_using_mpdf_api($html, 'reference_'.$node->nid.'_short'); // Generate Standard EN version $view = node_view($node, 'pdf_en'); $html = drupal_render($view); pdf_using_mpdf_api($html, 'reference_'.$node->nid.'_en'); // Generate short EN version $view = node_view($node, 'pdf_short_en'); $html = drupal_render($view); pdf_using_mpdf_api($html, 'reference_'.$node->nid.'_short_en'); }
this code above generates 4 pdf files correctly and save them under default/files/pdf_using_mpdf
directory. users should be able to download these PDFs, so I added 4 fields in my content type for each PDF version (field_pdf1, field_pdf2, field_pdf3, field_pdf4).
I want to attach these stored files into their corresponding fields inside private directory (after success, i’ll remove them from default/files/pdf_using_mpdf directory).
Before Im used to use field_attach_update
to attach fields to a node, but for file fields how can I do this ?
What should be the value of the field : $node->field_pdf1['und'][0]['value']
? and how can I store them into private directory ?
Thanks in advance.