Search in sources :

Example 1 with IShape

use of com.itextpdf.kernel.geom.IShape in project i7j-pdfsweep by itext.

the class PdfCleanUpProcessor method writePath.

private void writePath(Path path) {
    PdfCanvas canvas = getCanvas();
    for (Subpath subpath : path.getSubpaths()) {
        canvas.moveTo((float) subpath.getStartPoint().getX(), (float) subpath.getStartPoint().getY());
        for (IShape segment : subpath.getSegments()) {
            if (segment instanceof BezierCurve) {
                List<Point> basePoints = segment.getBasePoints();
                Point p2 = basePoints.get(1);
                Point p3 = basePoints.get(2);
                Point p4 = basePoints.get(3);
                canvas.curveTo((float) p2.getX(), (float) p2.getY(), (float) p3.getX(), (float) p3.getY(), (float) p4.getX(), (float) p4.getY());
            } else {
                // segment is Line
                Point destination = segment.getBasePoints().get(1);
                canvas.lineTo((float) destination.getX(), (float) destination.getY());
            }
        }
        if (subpath.isClosed()) {
            canvas.closePath();
        }
    }
}
Also used : Subpath(com.itextpdf.kernel.geom.Subpath) PdfCanvas(com.itextpdf.kernel.pdf.canvas.PdfCanvas) Point(com.itextpdf.kernel.geom.Point) IShape(com.itextpdf.kernel.geom.IShape) BezierCurve(com.itextpdf.kernel.geom.BezierCurve)

Aggregations

BezierCurve (com.itextpdf.kernel.geom.BezierCurve)1 IShape (com.itextpdf.kernel.geom.IShape)1 Point (com.itextpdf.kernel.geom.Point)1 Subpath (com.itextpdf.kernel.geom.Subpath)1 PdfCanvas (com.itextpdf.kernel.pdf.canvas.PdfCanvas)1