PDFClown: как клонировать страницу - PullRequest
0 голосов
/ 29 июня 2018

Я хочу скопировать страницы из старого файла PDF в новый с помощью pdfclown.

До сих пор я пробовал следующее:

    File newFile = new File();
    Document document = newFile.getDocument();
    for (int pageNumber : pageNumbers) {
         document.getPages().add(oldFile.getDocument().getPages().get(pageNumber).clone(document));
    }

    return newFile;

К сожалению, NullPointer возникает при выполнении clone(document)

    java.lang.NullPointerException
    at org.pdfclown.files.IndirectObjects.addExternal(IndirectObjects.java:208)
    at org.pdfclown.objects.Cloner.visit(Cloner.java:357)
    at org.pdfclown.objects.Cloner.visit(Cloner.java:367)
    at org.pdfclown.objects.PdfReference.accept(PdfReference.java:94)
    at org.pdfclown.objects.Cloner.visit(Cloner.java:343)
    at org.pdfclown.objects.PdfDictionary.accept(PdfDictionary.java:161)
    at org.pdfclown.files.IndirectObjects.addExternal(IndirectObjects.java:208)
    at org.pdfclown.objects.Cloner.visit(Cloner.java:357)
    at org.pdfclown.objects.Cloner.visit(Cloner.java:367)
    at org.pdfclown.objects.PdfReference.accept(PdfReference.java:94)
    at org.pdfclown.objects.Cloner.visit(Cloner.java:318)
    at org.pdfclown.objects.PdfArray.accept(PdfArray.java:113)
    at org.pdfclown.files.IndirectObjects.addExternal(IndirectObjects.java:208)
    at org.pdfclown.objects.Cloner.visit(Cloner.java:357)
    at org.pdfclown.objects.Cloner.visit(Cloner.java:367)
    at org.pdfclown.objects.PdfReference.accept(PdfReference.java:94)
    at org.pdfclown.objects.Cloner.visit(Cloner.java:343)
    at org.pdfclown.objects.PdfDictionary.accept(PdfDictionary.java:161)
    at org.pdfclown.files.IndirectObjects.addExternal(IndirectObjects.java:208)
    at org.pdfclown.objects.Cloner.visit(Cloner.java:357)
    at org.pdfclown.objects.Cloner.visit(Cloner.java:367)
    at org.pdfclown.objects.PdfReference.accept(PdfReference.java:94)
    at org.pdfclown.objects.PdfObject.clone(PdfObject.java:96)
    at org.pdfclown.objects.PdfReference.clone(PdfReference.java:222)
    at org.pdfclown.objects.PdfReference.clone(PdfReference.java:1)
    at org.pdfclown.objects.PdfObjectWrapper.clone(PdfObjectWrapper.java:159)
...