As far as the PDF format is concerned, pages are pages: they aren't
truly considered to be 'front' or 'back'
That concept only becomes meaningful when the pages are rasterized onto a physical piece of paper, i.e. printed.
That doesn't mean PDF is completely ignorant of the concept.
There are a couple of ways it comes into play:
- PDF can carry an internal indicator of whether the document is intended to be printed in Duplex (there are a few options for this,
as mentioned in Joris's answer). However, these are really just
advisements to the print system you send it through. There is no
guarantee that a given print system will actually respect the
setting and put pages on both sides of the paper in the way you expect.
- The content of the PDF may be laid out as if it were to be printed duplex (e.g. mirrored page layouts, etc.). But this is just part of the content stream; the PDF format itself is agnostic (other than the options mentioned above).
So it's difficult to say a given page is 'front' or 'back'. You could check if the Duplex flag is set, and if it is, take the page number and divide by two: it's a front page if it's even and a back page if it's odd (remember that page numbers start with zero in PDF).
But there can still be edge cases.
For example, if you were to print a range (say pages 3-7), and you expect page 3 to be a 'back' page, the first page out of the printer likely won't be blank on it's front and have page 3 on the back (which is what you'd expect from what I suggested above).
Most printers will start on the front of the first sheet of paper, and your 'front' and 'back' pages will be out of order.