@Test
public void existingPage() throws IOException {

    try (PDDocument document = PDFParser.parse(SeekableSources.inMemorySeekableSourceFrom(
            getClass().getClassLoader().getResourceAsStream("pdf/shared_resource_dic_w_images.pdf")))) {
        PDPage page = document.getPage(0);
        PDPage copy = new PageCopier(false).copyOf(page);
        PDPage optimizedCopy = new PageCopier(true).copyOf(page);
        assertEquals(page.getMediaBox(), copy.getMediaBox());
        assertEquals(page.getCropBox(), copy.getCropBox());
        assertEquals(page.getRotation(), copy.getRotation());
        assertEquals(page.getResources(), copy.getResources());
        assertNotEquals(page.getResources(), optimizedCopy.getResources());
    }
}