package com.qmth.boot.test.tools.pdf;

import com.lowagie.text.pdf.PdfReader;
import com.qmth.boot.tools.models.ByteArray;
import com.qmth.boot.tools.pdf.PdfMergeFile;
import org.junit.Assert;
import org.junit.Test;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class PdfMergeTest {

    @Test
    public void test() throws IOException {
        ByteArrayOutputStream ous = new ByteArrayOutputStream();
        PdfMergeFile merge = new PdfMergeFile(ous);
        merge.merge(ByteArray.fromResource("template.pdf").value(), true)
                .merge(ByteArray.fromResource("template.pdf").value(), false);
        merge.close();
        PdfReader reader = new PdfReader(ous.toByteArray());
        Assert.assertEquals(3, reader.getNumberOfPages());
        reader.close();
    }
}
