import re


def _find_page_sizes(text):
    """Finds page sizes by the MediaBox attribute.
    Returns a list of width,height-tuples.
    Hack - this assumes that only pages have a MediaBox attribute.
    """
    re_mediabox = re.compile(r"/MediaBox \[(\d+ \d+ \d+ \d+)\]")
    sizes = []
    for m in re_mediabox.finditer(text):
        x,y,w,h = [int(item) for item in m.group(1).split(" ")]
        sizes.append((w,h))
    return sizes