package org.sejda.impl.sambox.util;

import org.sejda.impl.sambox.component.DefaultPdfSourceOpener;
import org.sejda.model.exception.TaskIOException;
import org.sejda.model.input.PdfStreamSource;
import org.sejda.sambox.pdmodel.PDDocument;

import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric;

public class TestUtils {

    public static PDDocument getTestDoc(String name) throws TaskIOException {
        PdfStreamSource source = PdfStreamSource.newInstanceNoPassword(
                TestUtils.class.getClassLoader().getResourceAsStream(name), randomAlphanumeric(16) + ".pdf");

        return new DefaultPdfSourceOpener().open(source).getUnderlyingPDDocument();
    }
}

@@ -143,16 +143,60 @@
 eption;%0A
+import org.sejda.model.input.PdfFileSource;%0A
 import o
@@ -225,32 +225,32 @@
 dfStreamSource;%0A
-
 import org.sejda
@@ -278,16 +278,38 @@
 ument;%0A%0A
+import java.io.File;%0A%0A
 import s
@@ -404,16 +404,16 @@
 tils %7B%0A%0A
-
     publ
@@ -482,16 +482,257 @@
 ption %7B%0A
+        File file = new File(name);%0A        if(file.exists()) %7B%0A            PdfFileSource source = PdfFileSource.newInstanceNoPassword(file);%0A            return new DefaultPdfSourceOpener().open(source).getUnderlyingPDDocument();%0A        %7D%0A%0A
         

Test doc: support paths to disk file