/** * Process a content stream. * * @param contentStream the content stream * @throws IOException if there is an exception while processing the stream */ private void processStream(PDContentStream contentStream) throws IOException { PDResources parent = pushResources(contentStream); Stack<PDGraphicsState> savedStack = saveGraphicsStack(); Matrix parentMatrix = initialMatrix; // transform the CTM using the stream's matrix getGraphicsState().getCurrentTransformationMatrix().concatenate(contentStream.getMatrix()); // the stream's initial matrix includes the parent CTM, e.g. this allows a scaled form initialMatrix = getGraphicsState().getCurrentTransformationMatrix().clone(); // clip to bounding box PDRectangle bbox = contentStream.getBBox(); clipToRect(bbox); // processStreamOperators(contentStream); initialMatrix = parentMatrix; restoreGraphicsStack(savedStack); popResources(parent); }