function pdf_to_imagefield_process_pdf in PDF to ImageField 6.2
Same name and namespace in other branches
- 7 pdf_to_imagefield.module \pdf_to_imagefield_process_pdf()
Given an node and a PDF file to process, do so.
This func is most often called from inside a batch process.
1 string reference to 'pdf_to_imagefield_process_pdf'
- pdf_to_imagefield_set_batch in ./
pdf_to_imagefield.module - Prepare the batch job to process a PDF file.
File
- ./
pdf_to_imagefield.module, line 220 - PDF to ImageField core hooks and menu callbacks.
Code
function pdf_to_imagefield_process_pdf($node, $source_file, $source_filefield_def) {
// Args may either be the full objects, or just identifiers for those objects : nid,fid, fieldname
if (is_numeric($node)) {
$node = node_load($node);
}
if (empty($node)) {
watchdog('pdf_to_imagefield', "Invalid node or node identifier in %function - Can't attach files to nothing, aborting", array(
'%function' => __FUNCTION__,
), WATCHDOG_ERROR);
return;
}
if (is_numeric($source_file)) {
$source_file = field_file_load($source_file);
}
if (is_string($source_filefield_def)) {
$source_filefield_def = content_fields($source_filefield_def);
}
$widget = $source_filefield_def['widget'];
$job = (object) array(
'density_x' => preg_replace('/^([0-9]+)x[0-9]+$/', '\\1', $widget['density']),
'density_y' => preg_replace('/^[0-9]+x([0-9]+)$/', '\\1', $widget['density']),
'extra_args' => $widget['extra_args'],
);
$images = pdf_to_imagefield_convert_pages($job, pdf_to_imagefield_widget_file_path($source_filefield_def), $source_file);
pdf_to_imagefield_attach_files($images, $node, $source_filefield_def['widget']['target_imagefield']);
return count($images);
}