您是否只需要在加載/保存操作后關(guān)閉 PDDocument 或制作每個新的 PDDocument 對象(例如,在執(zhí)行合并/拆分/...操作時)?例如,假設(shè)我有 3 個從字節(jié)數(shù)組加載的 PDDocument:PDDocument pdf1 = PDDocument.load(bytearray1);PDDocument pdf2 = PDDocument.load(bytearray2);PDDocument pdf3 = PDDocument.load(bytearray3);假設(shè)我然后將這 3 個 pdf 合并到一個 PDDocument 中:PdfMergerUtility merger = new PdfMergerUtility();PDDocument mergedPdf = new PDDocument();mergedDocument.appendDocument(mergedPdf, pdf1);mergedDocument.appendDocument(mergedPdf, pdf2);mergedDocument.appendDocument(mergedPdf, pdf3);我關(guān)閉了 3 個 pdf:pdf1.close();pdf2.close();pdf3.close();但是我現(xiàn)在必須關(guān)閉mergedPdf還是不需要?mergedPdf.close(); // is this needed?
你總是需要關(guān)閉一個新的 PDDocument 對象嗎?
呼喚遠(yuǎn)方
2022-07-14 10:11:20