commit
daa081d46d
|
@ -4,6 +4,7 @@ import cn.keking.config.ConfigConstants;
|
|||
import cn.keking.model.FileAttribute;
|
||||
import cn.keking.model.FileType;
|
||||
import cn.keking.service.cache.CacheService;
|
||||
import cn.keking.service.cache.NotResourceCache;
|
||||
import cn.keking.utils.KkFileUtils;
|
||||
import cn.keking.utils.WebUtils;
|
||||
import com.aspose.cad.CodePages;
|
||||
|
@ -198,6 +199,7 @@ public class FileHandlerService {
|
|||
return null;
|
||||
}
|
||||
PDDocument doc = PDDocument.load(pdfFile);
|
||||
doc.setResourceCache(new NotResourceCache());
|
||||
int pageCount = doc.getNumberOfPages();
|
||||
PDFRenderer pdfRenderer = new PDFRenderer(doc);
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package cn.keking.service.cache;
|
||||
|
||||
import org.apache.pdfbox.cos.COSObject;
|
||||
import org.apache.pdfbox.pdmodel.DefaultResourceCache;
|
||||
import org.apache.pdfbox.pdmodel.graphics.PDXObject;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author: Sawyer.Yong
|
||||
* @since: 2023/02/18 14:45
|
||||
* 解决图片 SoftReference 导致内存无法被回收导致的OOM, 详见 https://issues.apache.org/jira/browse/PDFBOX-3700
|
||||
*/
|
||||
public class NotResourceCache extends DefaultResourceCache {
|
||||
|
||||
@Override
|
||||
public void put(COSObject indirect, PDXObject xobject) throws IOException {
|
||||
// do nothing
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue