You are here

function pdf_to_imagefield_convert_pages in PDF to ImageField 6

Same name and namespace in other branches
  1. 6.2 pdf_to_imagefield.module \pdf_to_imagefield_convert_pages()
  2. 7 pdf_to_imagefield.module \pdf_to_imagefield_convert_pages()

Convert pages from pdf file to ImageField files

1 call to pdf_to_imagefield_convert_pages()
pdf_to_imagefield_cron in ./pdf_to_imagefield.module
Implementation of hook_cron().

File

./pdf_to_imagefield.module, line 114
PDF to ImageField core hooks and menu callbacks.

Code

function pdf_to_imagefield_convert_pages($file, $path, $pdf) {
  $source = $pdf['filepath'];
  $result = $path . '/' . $pdf['fid'] . '.jpg';
  $density = '-density ' . $file->density_x . 'x' . $file->density_y;
  pdf_to_imagefield_convert_pdf($source, $result, array(), array(
    $density,
  ));
  $count = 0;
  $converted = array();
  while (file_exists($path . '/' . $pdf['fid'] . '-' . $count . '.jpg')) {
    $filename = $pdf['fid'] . '-' . $count . '.jpg';
    $converted[] = pdf_to_imagefield_save_image($filename, $path);
    $count++;
  }
  db_query('UPDATE {pdf_to_imagefield} SET finished = %d WHERE fid = %d', time(), $pdf['fid']);
  return $converted;
}