use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.
the class PDFStreamEngine method processStream.
/**
* 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);
Deque<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);
}
use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.
the class PDFStreamEngine method processTilingPattern.
/**
* Process the given tiling pattern. Allows the pattern matrix to be overridden for custom
* rendering.
*
* @param tilingPattern the tiling pattern
* @param color color to use, if this is an uncoloured pattern, otherwise null.
* @param colorSpace color space to use, if this is an uncoloured pattern, otherwise null.
* @param patternMatrix the pattern matrix, may be overridden for custom rendering.
* @throws IOException if there is an error reading or parsing the tiling pattern content stream.
*/
protected final void processTilingPattern(PDTilingPattern tilingPattern, PDColor color, PDColorSpace colorSpace, Matrix patternMatrix) throws IOException {
PDResources parent = pushResources(tilingPattern);
Matrix parentMatrix = initialMatrix;
initialMatrix = Matrix.concatenate(initialMatrix, patternMatrix);
// save the original graphics state
Deque<PDGraphicsState> savedStack = saveGraphicsStack();
// save a clean state (new clipping path, line path, etc.)
RectF bbox = new RectF();
tilingPattern.getBBox().transform(patternMatrix).computeBounds(bbox, true);
PDRectangle rect = new PDRectangle((float) bbox.left, (float) bbox.top, (float) bbox.width(), (float) bbox.height());
graphicsStack.push(new PDGraphicsState(rect));
// non-colored patterns have to be given a color
if (colorSpace != null) {
color = new PDColor(color.getComponents(), colorSpace);
getGraphicsState().setNonStrokingColorSpace(colorSpace);
getGraphicsState().setNonStrokingColor(color);
getGraphicsState().setStrokingColorSpace(colorSpace);
getGraphicsState().setStrokingColor(color);
}
// transform the CTM using the stream's matrix
getGraphicsState().getCurrentTransformationMatrix().concatenate(patternMatrix);
// clip to bounding box
clipToRect(tilingPattern.getBBox());
processStreamOperators(tilingPattern);
initialMatrix = parentMatrix;
restoreGraphicsStack(savedStack);
popResources(parent);
}
use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.
the class FDFAnnotationFreeText method initFringe.
private void initFringe(Element element) throws IOException {
String fringe = element.getAttribute("fringe");
if (fringe != null && !fringe.isEmpty()) {
String[] fringeValues = fringe.split(",");
if (fringeValues.length != 4) {
throw new IOException("Error: wrong amount of numbers in attribute 'fringe'");
}
PDRectangle rect = new PDRectangle();
rect.setLowerLeftX(Float.parseFloat(fringeValues[0]));
rect.setLowerLeftY(Float.parseFloat(fringeValues[1]));
rect.setUpperRightX(Float.parseFloat(fringeValues[2]));
rect.setUpperRightY(Float.parseFloat(fringeValues[3]));
setFringe(rect);
}
}
use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.
the class FDFAnnotationSquare method initFringe.
private void initFringe(Element element) throws IOException {
String fringe = element.getAttribute("fringe");
if (fringe != null && !fringe.isEmpty()) {
String[] fringeValues = fringe.split(",");
if (fringeValues.length != 4) {
throw new IOException("Error: wrong amount of numbers in attribute 'fringe'");
}
PDRectangle rect = new PDRectangle();
rect.setLowerLeftX(Float.parseFloat(fringeValues[0]));
rect.setLowerLeftY(Float.parseFloat(fringeValues[1]));
rect.setUpperRightX(Float.parseFloat(fringeValues[2]));
rect.setUpperRightY(Float.parseFloat(fringeValues[3]));
setFringe(rect);
}
}
use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.
the class PDTilingPattern method getBBox.
/**
* An array of four numbers in the form coordinate system (see
* below), giving the coordinates of the left, bottom, right, and top edges,
* respectively, of the pattern's bounding box.
*
* @return The BBox of the pattern.
*/
@Override
public PDRectangle getBBox() {
PDRectangle retval = null;
COSBase base = getCOSObject().getDictionaryObject(COSName.BBOX);
if (base instanceof COSArray) {
retval = new PDRectangle((COSArray) base);
}
return retval;
}
Aggregations