-2

I would like to know if it is possible to get the dimensions of a PDF file when uploading.

My task is to quote according to the files length and width so I would like to know if there is a plugin that might get the dimensions of a PDF file. I read that PDF.js can get the pixels size but in millimeters this will change according to the DPI so I do not believe this will help me.

My current website is built using OctoberCMS, jquery and php

1 Answers1

0

Assume that every page is A4 page, A4 page is 210 × 297.

Now you need to get pages count from PDF, e.g. using Imagick:

$image = new Imagick();
$image->pingImage('file.pdf');
$pageCount = $image->getNumberImages();

And calculate how much to charge:

$price = 21*29.7 * 0.1 * $pageCount;
Justinas
  • 41,402
  • 5
  • 66
  • 96
  • Thanks for this, but I need to know if it is possible for javascript/jquery to get the page dimensions so that I can make that dynamic in the algorithm – Gareth Reynecke Oct 09 '17 at 09:12
  • @GarethReynecke You did not specify if it's JS or PHP. So I provided PHP – Justinas Oct 09 '17 at 09:16
  • Sorry man I think you misunderstand me. I am looking for any possible method to get the dimensions of the pdf file. My website is using php and jquery so either is fine, I just need to know if it is possible for a script to tell me how wide and how long a pdf file is – Gareth Reynecke Oct 09 '17 at 09:23
  • @GarethReynecke Then try this: https://stackoverflow.com/questions/19042950/how-do-i-determine-the-size-of-a-pdf-with-pdf-js-so-i-can-scale-to-the-screen-si – Justinas Oct 09 '17 at 09:29