Woher kann ich wissen, ob der Pfad des Clips im normalen Schlaganfall oder im Füllweg enthalten ist?Java

Java-Forum
Anonymous
 Woher kann ich wissen, ob der Pfad des Clips im normalen Schlaganfall oder im Füllweg enthalten ist?

Post by Anonymous »

Ich benutze PDFBox 3.0.2, um den Ausschnittpfad und den normalen Pfad in der PDF zu erhalten, aber ich bin mir nicht sicher, ob der von mir erhalte Ausschnittpfad mit dem normalen Pfad verbunden ist, oder ob der Clipping -Pfad in den normalen Pfad enthalten ist. Manchmal bekomme ich viele Clips, aber ich bin mir nicht sicher, ob dieser Clip. />

Code: Select all

@Override
public void endPath() throws IOException {}
< /code>
< /blockquote>
Mein normaler Pfad wird unter Verwendung der folgenden Methode < /p>

erhalten@Override
public void strokePath() {}
@Override
public void fillPath(int i) {}
< /code>
< /blockquote>

@Override
public void endPath() throws IOException {
if (clipWindingRule != -1) {
linePath.setWindingRule(clipWindingRule);
Rectangle2D bounds = linePath.getBounds2D();
ClipPathInfo info = new ClipPathInfo();
Area currentClippingPath = getGraphicsState().getCurrentClippingPath();
if (clipWindingRule == PathIterator.WIND_EVEN_ODD) {
info.setRule("Even-Odd");
} else {
info.setRule("NonZero");
}

Matrix ctm = getGraphicsState().getCurrentTransformationMatrix();

PDRectangle cropBox = page.getCropBox();
float pageHeight = cropBox.getHeight();

double x = bounds.getX() * scale;
double y = (pageHeight - bounds.getY() - bounds.getHeight()) * scale;
double width = bounds.getWidth() * scale;
double height = bounds.getHeight() * scale;

Matrix matrix = new Matrix();
matrix.scale(1, -1);
matrix.translate(0, (float) -y);
matrix.scale(scale, scale);
Matrix multiply = matrix.multiply(ctm);

double[][] mCTMatrix = {
{multiply.getScaleX(), multiply.getShearY(), 0},
{multiply.getShearX(), multiply.getScaleY(), 0},
{multiply.getTranslateX(), multiply.getTranslateY(), 1},
};
info.setCtm(mCTMatrix);

info.setBoundary(new OfdBoxImpl(x, y, width, height));

AbbreviatedData data = new AbbreviatedData();
drawLine(linePath.getPathIterator(null), data, pageHeight * scale, true);
info.setData(data);
clipPathInfos.add(info);
clipWindingRule = -1;}linePath.reset();
< /code>
< /blockquote>
@Override
public void appendRectangle(Point2D p0, Point2D p1, Point2D p2, Point2D p3) {
linePath.moveTo((float) p0.getX(), (float) p0.getY());
linePath.lineTo((float) p1.getX(), (float) p1.getY());
linePath.lineTo((float) p2.getX(), (float) p2.getY());
linePath.lineTo((float) p3.getX(), (float) p3.getY());
linePath.closePath();
}

private void drawLine(PathIterator iterator, AbbreviatedData data, float height, boolean isPath) throws IOException {
double[] coords = new double[6];
while (!iterator.isDone()) {
switch (iterator.currentSegment(coords)) {
case SEG_MOVETO:
data.moveTo(coords[0] * scale, height - coords[1] * scale);
break;
case SEG_LINETO:
data.lineTo(coords[0] * scale, height - coords[1] * scale);
break;
case SEG_CUBICTO:
data.B(coords[0] * scale, height - coords[1] * scale,
coords[2] * scale, height - coords[3] * scale,
coords[4] * scale, height - coords[5] * scale);
break;
case SEG_CLOSE:
data.close();
if (isPath) {
closePath();
}
break;
default:
break;
}
iterator.next();
}
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post