This will take a document and split into several other documents. @param document The document to split. @return A list of all the split documents. These should all be saved before closing any documents, including the source document. Any further operations should be made after reloading them, to
(PDDocument document)
| 125 | * @throws IOException If there is an IOError |
| 126 | */ |
| 127 | public List<PDDocument> split(PDDocument document) throws IOException |
| 128 | { |
| 129 | // reset the currentPageNumber for a case if the split method will be used several times |
| 130 | currentPageNumber = 0; |
| 131 | destinationDocuments = new ArrayList<>(); |
| 132 | sourceDocument = document; |
| 133 | pageDictMaps = new ArrayList<>(); |
| 134 | annotDictMaps = new ArrayList<>(); |
| 135 | destToFixMap = new HashMap<>(); |
| 136 | idSet = new HashSet<>(); |
| 137 | roleSet = new HashSet<>(); |
| 138 | |
| 139 | processPages(); |
| 140 | |
| 141 | for (int i = 0; i < destinationDocuments.size(); ++i) |
| 142 | { |
| 143 | PDDocument destinationDocument = destinationDocuments.get(i); |
| 144 | pageDictMap = pageDictMaps.get(i); |
| 145 | annotDictMap = annotDictMaps.get(i); |
| 146 | cloneStructureTree(destinationDocument); |
| 147 | fixDestinations(destinationDocument); |
| 148 | } |
| 149 | |
| 150 | return destinationDocuments; |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * Replace the page destinations, if the source and destination pages are in the target |