Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
litvinovg committed Apr 23, 2019
1 parent 9ca2dba commit b082785
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/main/java/ru/ras/iph/impose/splitByOutline.java
Expand Up @@ -102,20 +102,25 @@ public static void main(String[] args) throws IOException, DocumentException {
// PdfWriter writer = PdfWriter.getInstance(document, os);
PdfCopy writer = new PdfCopy(document, os);

int pageCount = 0;
document.open();
for (int i = 1; i <= reader.getNumberOfPages(); i++) {
if (pageNums.contains(i)) {
//close current document
document.close();
outputFile = new File( parentFolder + i + "_" + inputFile.getName());
document = new Document(reader.getPageSizeWithRotation(i));
os = new FileOutputStream(outputFile);
writer.close();
writer = new PdfCopy(document, os);
document.open();
if (pageCount != 0) {
pageCount = 0;
//close current document
document.close();
outputFile = new File( parentFolder + i + "_" + inputFile.getName());
document = new Document(reader.getPageSizeWithRotation(i));
os = new FileOutputStream(outputFile);
writer.close();
writer = new PdfCopy(document, os);
document.open();
}

}
PdfImportedPage page1 = writer.getImportedPage(reader, i);
pageCount++;
writer.addPage(page1);
}
document.close();
Expand Down

0 comments on commit b082785

Please sign in to comment.