Skip to content

Commit

Permalink
For #94 - Cleanup thread local on cleanup of PdfBoxRenderer.
Browse files Browse the repository at this point in the history
Thanks @rototor
  • Loading branch information
danfickle committed May 11, 2017
1 parent 057d137 commit 96b3edd
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
import com.openhtmltopdf.resource.XMLResource;
import com.openhtmltopdf.simple.extend.XhtmlNamespaceHandler;
import com.openhtmltopdf.util.Configuration;
import com.openhtmltopdf.util.ThreadCtx;
import com.openhtmltopdf.util.XRLog;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentInformation;
import org.apache.pdfbox.pdmodel.PDPage;
Expand All @@ -57,6 +59,7 @@
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.io.*;
Expand Down Expand Up @@ -764,7 +767,11 @@ public void setListener(PDFCreationListener listener) {
_listener = listener;
}

/**
* Cleanup thread resources. MUST be called after finishing with the renderer.
*/
public void cleanup() {
_sharedContext.removeFromThread();
ThreadCtx.cleanup();
}
}

0 comments on commit 96b3edd

Please sign in to comment.