package com.knecon.fforesight.service.layoutparser.processor.services.graphics;

import java.awt.geom.Rectangle2D;

import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.common.PDRectangle;

public record PageInformation(Rectangle2D mediabox, int number, int rotationDegrees) {

    public static PageInformation fromPDPage(int pageNum, PDPage page) {

        PDRectangle mediaBox = page.getMediaBox();
        return new PageInformation(new Rectangle2D.Double(mediaBox.getLowerLeftX(), mediaBox.getLowerLeftY(), mediaBox.getWidth(), mediaBox.getHeight()),
                pageNum,
                page.getRotation());
    }


    public double height() {

        return mediabox.getHeight();
    }


    public double width() {

        return mediabox.getWidth();
    }


    public double minX() {

        return mediabox.getX();
    }


    public double minY() {

        return mediabox.getY();
    }

}