Fix chiusura file nel merge dei pdf

This commit is contained in:
Silvano Trinchero 2018-04-10 17:12:02 +02:00
parent 887e0846be
commit 9c5045333e
1 changed files with 34 additions and 17 deletions

View File

@ -24,6 +24,7 @@ import java.io.IOException;
import java.lang.ref.WeakReference;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
@ -592,9 +593,17 @@ public final class AEnv
DocumentException, FileNotFoundException {
Document document = null;
PdfWriter copy = null;
List<PdfReader> pdfReaders = new ArrayList<PdfReader>();
try
{
for (File f : pdfList)
{
PdfReader reader = new PdfReader(f.getAbsolutePath());
pdfReaders.add(reader);
if (document == null)
{
document = new Document(reader.getPageSizeWithRotation(1));
@ -613,6 +622,14 @@ public final class AEnv
}
document.close();
}
finally
{
for(PdfReader reader:pdfReaders)
{
reader.close();
}
}
}
/**
* Get window title