pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1800894 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java
Date Wed, 05 Jul 2017 16:11:17 GMT
Author: tilman
Date: Wed Jul  5 16:11:17 2017
New Revision: 1800894

URL: http://svn.apache.org/viewvc?rev=1800894&view=rev
Log:
PDFBOX-3852: avoid identical resources, as suggested by ryuukei

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java?rev=1800894&r1=1800893&r2=1800894&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java Wed Jul
 5 16:11:17 2017
@@ -102,12 +102,20 @@ public class Overlay
     public PDDocument overlay(Map<Integer, String> specificPageOverlayFile)
             throws IOException
     {
+        Map<String, PDDocument> loadedDocuments = new HashMap<String, PDDocument>();
+        Map<PDDocument, LayoutPage> layouts = new HashMap<PDDocument, LayoutPage>();
         loadPDFs();
         for (Map.Entry<Integer, String> e : specificPageOverlayFile.entrySet())
         {
-            PDDocument doc = loadPDF(e.getValue());
+            PDDocument doc = loadedDocuments.get(e.getValue());
+            if (doc == null)
+            {
+                doc = loadPDF(e.getValue());
+                loadedDocuments.put(e.getValue(), doc);
+                layouts.put(doc, getLayoutPage(doc));
+            }
             specificPageOverlay.put(e.getKey(), doc);
-            specificPageOverlayPage.put(e.getKey(), getLayoutPage(doc));
+            specificPageOverlayPage.put(e.getKey(), layouts.get(doc));
         }
         processPages(inputPDFDocument);
         return inputPDFDocument;



Mime
View raw message