private RenderResult renderCurrentPage(PDPage pdPage, ParseContext parseContext,
                                           TemporaryResources tmpResources)
            throws IOException, TikaException {
        PDFRenderingState renderingState = parseContext.get(PDFRenderingState.class);
        if (renderingState == null) {
            Metadata pageMetadata = getCurrentPageMetadata(pdPage);
            noContextRenderCurrentPage(pageMetadata, parseContext, tmpResources);
        }
        //if the full document has already been rendered, then reuse that file
        //TODO: we need to prevent this if only a portion of the page or portions
        //of the page have been rendered.
        //TODO: we should also figure out how to not reuse the rendering if
        //the user wants to render twice (say, full color to display to users, but
        //grayscale for (notionally?) better OCR).
        PageBasedRenderResults results = (PageBasedRenderResults) renderingState.getRenderResults();
        if (results != null) {
            List<RenderResult> pageResults = results.getPage(getCurrentPageNo());
            if (pageResults.size() == 1) {
                return pageResults.get(0);
            }
        }
        Metadata pageMetadata = getCurrentPageMetadata(pdPage);
        Renderer thisRenderer = getPDFRenderer(config.getRenderer());
        //if there's a configured renderer and if the rendering strategy is "all"
        if (thisRenderer != null &&
                config.getOcrRenderingStrategy() == PDFParserConfig.OCR_RENDERING_STRATEGY.ALL) {
            PageRangeRequest pageRangeRequest =
                    new PageRangeRequest(getCurrentPageNo(), getCurrentPageNo());
            if (thisRenderer instanceof PDDocumentRenderer) {
                //do not do autocloseable.  We need to leave the pdDocument open!
                TikaInputStream tis = TikaInputStream.get(new byte[0]);
                tis.setOpenContainer(pdDocument);
                return thisRenderer.render(tis, pageMetadata, parseContext, pageRangeRequest)
                        .getResults().get(0);

            } else {
                PDFRenderingState state = context.get(PDFRenderingState.class);
                if (state == null) {
                    throw new IllegalArgumentException("RenderingState must not be null");
                }
                return thisRenderer.render(state.getTikaInputStream(), pageMetadata, parseContext,
                        pageRangeRequest).getResults().get(0);
            }
        } else {
            return noContextRenderCurrentPage(pageMetadata, parseContext, tmpResources);
        }
    }
Format used for signature dates
TODO Make this thread-safe
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-pdf-module/src/main/java/org/apache/tika/parser/pdf/AbstractPDF2XHTML.java