package com.knecon.fforesight.service.viewerdoc.pdf;

import java.io.IOException;
import java.io.InputStream;

import org.apache.pdfbox.contentstream.PDContentStream;
import org.apache.pdfbox.io.RandomAccessInputStream;
import org.apache.pdfbox.io.RandomAccessRead;
import org.apache.pdfbox.pdmodel.PDResources;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.common.PDStream;
import org.apache.pdfbox.util.Matrix;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;

@Getter
@RequiredArgsConstructor
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
public class SinglePDContentStream implements PDContentStream {

    PDStream pdStream;


    @Override
    public InputStream getContents() throws IOException {

        return new RandomAccessInputStream(getContentsForRandomAccess());
    }


    @Override
    public RandomAccessRead getContentsForRandomAccess() throws IOException {

        return pdStream.getCOSObject().createView();
    }


    @Override
    public PDResources getResources() {

        return null;
    }


    @Override
    public PDRectangle getBBox() {

        return null;
    }


    @Override
    public Matrix getMatrix() {

        return null;
    }

}
