⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pdfcontentbyte.java

📁 一个java操作pdf文件的开发包,很好用的.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    /**     * Changes the currentgray tint for stroking paths (device dependent colors!).     * <P>     * Sets the color space to <B>DeviceGray</B> (or the <B>DefaultGray</B> color space),     * and sets the gray tint to use for stroking paths.</P>     *     * @param	gray	a value between 0 (black) and 1 (white)     */        public void setGrayStroke(float gray) {        content.append(gray).append(" G").append_i(separator);    }        /**     * Changes the current gray tint for stroking paths to black.     */        public void resetGrayStroke() {        content.append("0 G").append_i(separator);    }        /**     * Helper to validate and write the RGB color components     * @param	red		the intensity of red. A value between 0 and 1     * @param	green	the intensity of green. A value between 0 and 1     * @param	blue	the intensity of blue. A value between 0 and 1     */    private void HelperRGB(float red, float green, float blue) {        if (red < 0)            red = 0.0f;        else if (red > 1.0f)            red = 1.0f;        if (green < 0)            green = 0.0f;        else if (green > 1.0f)            green = 1.0f;        if (blue < 0)            blue = 0.0f;        else if (blue > 1.0f)            blue = 1.0f;        content.append(red).append(' ').append(green).append(' ').append(blue);    }        /**     * Changes the current color for filling paths (device dependent colors!).     * <P>     * Sets the color space to <B>DeviceRGB</B> (or the <B>DefaultRGB</B> color space),     * and sets the color to use for filling paths.</P>     * <P>     * Following the PDF manual, each operand must be a number between 0 (minimum intensity) and     * 1 (maximum intensity).</P>     *     * @param	red		the intensity of red. A value between 0 and 1     * @param	green	the intensity of green. A value between 0 and 1     * @param	blue	the intensity of blue. A value between 0 and 1     */        public void setRGBColorFillF(float red, float green, float blue) {        HelperRGB(red, green, blue);        content.append(" rg").append_i(separator);    }        /**     * Changes the current color for filling paths to black.     */        public void resetRGBColorFill() {        content.append("0 0 0 rg").append_i(separator);    }        /**     * Changes the current color for stroking paths (device dependent colors!).     * <P>     * Sets the color space to <B>DeviceRGB</B> (or the <B>DefaultRGB</B> color space),     * and sets the color to use for stroking paths.</P>     * <P>     * Following the PDF manual, each operand must be a number between 0 (miniumum intensity) and     * 1 (maximum intensity).     *     * @param	red		the intensity of red. A value between 0 and 1     * @param	green	the intensity of green. A value between 0 and 1     * @param	blue	the intensity of blue. A value between 0 and 1     */        public void setRGBColorStrokeF(float red, float green, float blue) {        HelperRGB(red, green, blue);        content.append(" RG").append_i(separator);    }        /**     * Changes the current color for stroking paths to black.     *     */        public void resetRGBColorStroke() {        content.append("0 0 0 RG").append_i(separator);    }        /**     * Helper to validate and write the CMYK color components.     *     * @param	cyan	the intensity of cyan. A value between 0 and 1     * @param	magenta	the intensity of magenta. A value between 0 and 1     * @param	yellow	the intensity of yellow. A value between 0 and 1     * @param	black	the intensity of black. A value between 0 and 1     */    private void HelperCMYK(float cyan, float magenta, float yellow, float black) {        if (cyan < 0)            cyan = 0.0f;        else if (cyan > 1.0f)            cyan = 1.0f;        if (magenta < 0)            magenta = 0.0f;        else if (magenta > 1.0f)            magenta = 1.0f;        if (yellow < 0)            yellow = 0.0f;        else if (yellow > 1.0f)            yellow = 1.0f;        if (black < 0)            black = 0.0f;        else if (black > 1.0f)            black = 1.0f;        content.append(cyan).append(' ').append(magenta).append(' ').append(yellow).append(' ').append(black);    }        /**     * Changes the current color for filling paths (device dependent colors!).     * <P>     * Sets the color space to <B>DeviceCMYK</B> (or the <B>DefaultCMYK</B> color space),     * and sets the color to use for filling paths.</P>     * <P>     * Following the PDF manual, each operand must be a number between 0 (no ink) and     * 1 (maximum ink).</P>     *     * @param	cyan	the intensity of cyan. A value between 0 and 1     * @param	magenta	the intensity of magenta. A value between 0 and 1     * @param	yellow	the intensity of yellow. A value between 0 and 1     * @param	black	the intensity of black. A value between 0 and 1     */        public void setCMYKColorFillF(float cyan, float magenta, float yellow, float black) {        HelperCMYK(cyan, magenta, yellow, black);        content.append(" k").append_i(separator);    }        /**     * Changes the current color for filling paths to black.     *     */        public void resetCMYKColorFill() {        content.append("0 0 0 1 k").append_i(separator);    }        /**     * Changes the current color for stroking paths (device dependent colors!).     * <P>     * Sets the color space to <B>DeviceCMYK</B> (or the <B>DefaultCMYK</B> color space),     * and sets the color to use for stroking paths.</P>     * <P>     * Following the PDF manual, each operand must be a number between 0 (miniumum intensity) and     * 1 (maximum intensity).     *     * @param	cyan	the intensity of cyan. A value between 0 and 1     * @param	magenta	the intensity of magenta. A value between 0 and 1     * @param	yellow	the intensity of yellow. A value between 0 and 1     * @param	black	the intensity of black. A value between 0 and 1     */        public void setCMYKColorStrokeF(float cyan, float magenta, float yellow, float black) {        HelperCMYK(cyan, magenta, yellow, black);        content.append(" K").append_i(separator);    }        /**     * Changes the current color for stroking paths to black.     *     */        public void resetCMYKColorStroke() {        content.append("0 0 0 1 K").append_i(separator);    }        /**     * Move the current point <I>(x, y)</I>, omitting any connecting line segment.     *     * @param		x				new x-coordinate     * @param		y				new y-coordinate     */        public void moveTo(float x, float y) {        content.append(x).append(' ').append(y).append(" m").append_i(separator);    }        /**     * Appends a straight line segment from the current point <I>(x, y)</I>. The new current     * point is <I>(x, y)</I>.     *     * @param		x				new x-coordinate     * @param		y				new y-coordinate     */        public void lineTo(float x, float y) {        content.append(x).append(' ').append(y).append(" l").append_i(separator);    }        /**     * Appends a B陑ier curve to the path, starting from the current point.     *     * @param		x1		x-coordinate of the first control point     * @param		y1		y-coordinate of the first control point     * @param		x2		x-coordinate of the second control point     * @param		y2		y-coordinate of the second control point     * @param		x3		x-coordinaat of the ending point (= new current point)     * @param		y3		y-coordinaat of the ending point (= new current point)     */        public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3) {        content.append(x1).append(' ').append(y1).append(' ').append(x2).append(' ').append(y2).append(' ').append(x3).append(' ').append(y3).append(" c").append_i(separator);    }        /**     * Appends a B陑ier curve to the path, starting from the current point.     *     * @param		x2		x-coordinate of the second control point     * @param		y2		y-coordinate of the second control point     * @param		x3		x-coordinaat of the ending point (= new current point)     * @param		y3		y-coordinaat of the ending point (= new current point)     */        public void curveTo(float x2, float y2, float x3, float y3) {        content.append(x2).append(' ').append(y2).append(' ').append(x3).append(' ').append(y3).append(" v").append_i(separator);    }        /**     * Appends a B陑ier curve to the path, starting from the current point.     *     * @param		x1		x-coordinate of the first control point     * @param		y1		y-coordinate of the first control point     * @param		x3		x-coordinaat of the ending point (= new current point)     * @param		y3		y-coordinaat of the ending point (= new current point)     */        public void curveFromTo(float x1, float y1, float x3, float y3) {        content.append(x1).append(' ').append(y1).append(' ').append(x3).append(' ').append(y3).append(" y").append_i(separator);    }        /** Draws a circle. The endpoint will (x+r, y).     *     * @param x x center of circle     * @param y y center of circle     * @param r radius of circle     */    public void circle(float x, float y, float r) {        float b = 0.5523f;        moveTo(x + r, y);        curveTo(x + r, y + r * b, x + r * b, y + r, x, y + r);        curveTo(x - r * b, y + r, x - r, y + r * b, x - r, y);        curveTo(x - r, y - r * b, x - r * b, y - r, x, y - r);        curveTo(x + r * b, y - r, x + r, y - r * b, x + r, y);    }                /**     * Adds a rectangle to the current path.     *     * @param		x		x-coordinate of the starting point     * @param		y		y-coordinate of the starting point     * @param		w		width     * @param		h		height     */        public void rectangle(float x, float y, float w, float h) {        content.append(x).append(' ').append(y).append(' ').append(w).append(' ').append(h).append(" re").append_i(separator);    }        /**     * Adds a border (complete or partially) to the current path..     *     * @param		rectangle		a <CODE>Rectangle</CODE>     */        public void rectangle(Rectangle rectangle) {                // the coordinates of the border are retrieved        float x1 = rectangle.left();        float y1 = rectangle.top();        float x2 = rectangle.right();        float y2 = rectangle.bottom();                // the backgroundcolor is set        Color background = rectangle.backgroundColor();        if (background != null) {            setColorStroke(background);            setColorFill(background);            rectangle(x1, y1, x2 - x1, y2 - y1);            closePathFillStroke();            resetRGBColorFill();            resetRGBColorStroke();        }        else if (rectangle.grayFill() > 0.0) {            setGrayStroke((float)rectangle.grayFill());            setGrayFill((float)rectangle.grayFill());            rectangle(x1, y1, x2 - x1, y2 - y1);            closePathFillStroke();            resetGrayFill();            resetGrayStroke();        }                        // if the element hasn't got any borders, nothing is added        if (! rectangle.hasBorders()) {            return;        }                // the width is set to the width of the element        if (rectangle.borderWidth() != Rectangle.UNDEFINED) {            setLineWidth((float)rectangle.borderWidth());        }                // the color is set to the color of the element        Color color = rectangle.borderColor();        if (color != null) {            setColorStroke(color);        }                // if the box is a rectangle, it is added as a rectangle        if (rectangle.hasBorder(Rectangle.BOX)) {            rectangle(x1, y1, x2 - x1, y2 - y1);        }        // if the border isn't a rectangle, the different sides are added apart        else {            if (rectangle.hasBorder(Rectangle.RIGHT)) {                moveTo(x2, y1);                lineTo(x2, y2);            }            if (rectangle.hasBorder(Rectangle.LEFT)) {                moveTo(x1, y1);                lineTo(x1, y2);            }            if (rectangle.hasBorder(Rectangle.BOTTOM)) {                moveTo(x1, y2);                lineTo(x2, y2);            }            if (rectangle.hasBorder(Rectangle.TOP)) {                moveTo(x1, y1);                lineTo(x2, y1);            }        }                stroke();                if (color != null) {            resetRGBColorStroke();        }    }        /**     * Closes the current subpath by appending a straight line segment from the current point     * to the starting point of the subpath.     */        public void closePath() {        content.append("h").append_i(separator);    }        /**     * Ends the path without filling or stroking it.     */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -