mirror of
https://github.com/sismics/docs.git
synced 2024-12-24 04:03:49 +01:00
Close all PDDocument
This commit is contained in:
parent
2c7083aa43
commit
2289f523c4
@ -153,12 +153,17 @@ public class FileUtil {
|
||||
image = ImageIO.read(originalFile);
|
||||
} else if(file.getMimeType().equals(MimeType.APPLICATION_PDF)) {
|
||||
// Generate preview from the first page of the PDF
|
||||
PDDocument pdfDocument = PDDocument.load(originalFile.getAbsolutePath(), true);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<PDPage> pageList = pdfDocument.getDocumentCatalog().getAllPages();
|
||||
if (pageList.size() > 0) {
|
||||
PDPage page = pageList.get(0);
|
||||
image = page.convertToImage();
|
||||
PDDocument pdfDocument = null;
|
||||
try {
|
||||
pdfDocument = PDDocument.load(originalFile.getAbsolutePath(), true);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<PDPage> pageList = pdfDocument.getDocumentCatalog().getAllPages();
|
||||
if (pageList.size() > 0) {
|
||||
PDPage page = pageList.get(0);
|
||||
image = page.convertToImage();
|
||||
}
|
||||
} finally {
|
||||
pdfDocument.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,15 +251,15 @@ public class DocumentResource extends BaseResource {
|
||||
if (params[1].length() == 10) {
|
||||
DateTime date = dayFormatter.parseDateTime(params[1]);
|
||||
documentCriteria.setCreateDateMin(date.toDate());
|
||||
documentCriteria.setCreateDateMax(date.plusDays(1).toDate());
|
||||
documentCriteria.setCreateDateMax(date.plusDays(1).minusSeconds(1).toDate());
|
||||
} else if (params[1].length() == 7) {
|
||||
DateTime date = monthFormatter.parseDateTime(params[1]);
|
||||
documentCriteria.setCreateDateMin(date.toDate());
|
||||
documentCriteria.setCreateDateMax(date.plusMonths(1).toDate());
|
||||
documentCriteria.setCreateDateMax(date.plusMonths(1).minusSeconds(1).toDate());
|
||||
} else if (params[1].length() == 4) {
|
||||
DateTime date = yearFormatter.parseDateTime(params[1]);
|
||||
documentCriteria.setCreateDateMin(date.toDate());
|
||||
documentCriteria.setCreateDateMax(date.plusYears(1).toDate());
|
||||
documentCriteria.setCreateDateMax(date.plusYears(1).minusSeconds(1).toDate());
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
// NOP
|
||||
|
@ -2,4 +2,5 @@ log4j.rootCategory=WARN, MEMORY
|
||||
log4j.appender.MEMORY=com.sismics.util.log4j.MemoryAppender
|
||||
log4j.appender.MEMORY.size=1000
|
||||
|
||||
log4j.logger.com.sismics=INFO
|
||||
log4j.logger.com.sismics=INFO
|
||||
log4j.logger.org.apache.pdfbox=ERROR
|
Loading…
Reference in New Issue
Block a user