### Question:
DrawContext implements Closeable { public DrawContext clip() { if (this.workPathObj == null) { return this; } if (state.clipFactory == null) { state.clipFactory = new ClipFactory(); } if (this.state.ctm != null) { state.clipFactory.setCtm(this.state.ctm.clone()); } state.clipFactory.setData(pathData.clone()); return this; } private  DrawContext();  DrawContext(CT_PageBlock container,
                       ST_Box boundary,
                       AtomicInteger maxUnitID,
                       ResManager resManager); DrawContext beginPath(); DrawContext closePath(); DrawContext clip(); DrawContext moveTo(double x, double y); DrawContext lineTo(double x, double y); DrawContext quadraticCurveTo(double cpx, double cpy, double x, double y); DrawContext bezierCurveTo(double cp1x, double cp1y,
                                     double cp2x, double cp2y,
                                     double x, double y); DrawContext arc(double a, double b,
                           double angle,
                           boolean large,
                           boolean sweep,
                           double x, double y); DrawContext arc(double x, double y,
                           double r,
                           double sAngle, double eAngle,
                           boolean counterclockwise); DrawContext arc(double x, double y,
                           double r,
                           double sAngle, double eAngle); DrawContext rect(double x, double y, double width, double height); DrawContext fillRect(double x, double y, double width, double height); DrawContext strokeRect(double x, double y, double width, double height); DrawContext stroke(); DrawContext fill(); DrawContext scale(double scalewidth, double scaleheight); DrawContext rotate(double angle); DrawContext translate(double x, double y); DrawContext transform(double a, double b, double c, double d, double e, double f); DrawContext setTransform(double a, double b, double c, double d, double e, double f); DrawContext drawImage(Path img,
                                 double x, double y,
                                 double width, double height); DrawContext save(); DrawContext restore(); DrawContext fillText(String text, double x, double y); TextAlign getTextAlign(); DrawContext setTextAlign(TextAlign textAlign); TextMetrics measureText(String text); int[] getStrokeColor(); DrawContext setStrokeColor(int[] strokeColor); DrawContext setStrokeColor(int r, int g, int b); int[] getFillColor(); DrawContext setFillColor(int[] fillColor); DrawContext setFillColor(int r, int g, int b); double getLineWidth(); DrawContext setLineWidth(double lineWidth); FontSetting getFont(); DrawContext setFont(FontSetting font); Double getGlobalAlpha(); DrawContext setGlobalAlpha(Double globalAlpha); DrawContext setLineCap(LineCapType cap); LineCapType getLineCap(); DrawContext setLineJoin(LineJoinType join); LineJoinType getLineJoin(); DrawContext setMiterLimit(Double miterLimit); Double getMiterLimit(); DrawContext setLineDash(Double dashOffset, Double[] pattern); DrawContext setLineDash(Double... pattern); ST_Array getDashPattern(); Double getDashOffset(); @Override void close();  }### Answer:
@Test void clip() throws IOException { Path outP = Paths.get("target/Canvas-clip.ofd"); try (OFDDoc ofdDoc = new OFDDoc(outP)) { VirtualPage vPage = new VirtualPage(ofdDoc.getPageLayout()); Canvas canvas = new Canvas(200d, 200d); canvas.setPosition(Position.Absolute) .setX(5d).setY(45d) .setBorder(1d); canvas.setDrawer(ctx -> { ctx.rect(50, 20, 200, 120); ctx.stroke(); ctx.clip(); ctx.setFillColor(0, 255, 0); ctx.fillRect(0, 0, 150, 100); }); vPage.add(canvas); ofdDoc.addVPage(vPage); } System.out.println("生成文档位置：" + outP.toAbsolutePath().toString()); }