📄 pdfcontentbyte.java
字号:
* Changes the value of the <VAR>line dash pattern</VAR>.
* <P>
* The line dash pattern controls the pattern of dashes and gaps used to stroke paths.
* It is specified by an <I>array</I> and a <I>phase</I>. The array specifies the length
* of the alternating dashes and gaps. The phase specifies the distance into the dash
* pattern to start the dash.<BR>
*
* @param phase the value of the phase
* @param unitsOn the number of units that must be 'on' (equals the number of units that must be 'off').
*/
public void setLineDash(float unitsOn, float phase) {
content.append("[").append(unitsOn).append("] ").append(phase).append(" d").append_i(separator);
}
/**
* Changes the value of the <VAR>line dash pattern</VAR>.
* <P>
* The line dash pattern controls the pattern of dashes and gaps used to stroke paths.
* It is specified by an <I>array</I> and a <I>phase</I>. The array specifies the length
* of the alternating dashes and gaps. The phase specifies the distance into the dash
* pattern to start the dash.<BR>
*
* @param phase the value of the phase
* @param unitsOn the number of units that must be 'on'
* @param unitsOff the number of units that must be 'off'
*/
public void setLineDash(float unitsOn, float unitsOff, float phase) {
content.append("[").append(unitsOn).append(' ').append(unitsOff).append("] ").append(phase).append(" d").append_i(separator);
}
/**
* Changes the value of the <VAR>line dash pattern</VAR>.
* <P>
* The line dash pattern controls the pattern of dashes and gaps used to stroke paths.
* It is specified by an <I>array</I> and a <I>phase</I>. The array specifies the length
* of the alternating dashes and gaps. The phase specifies the distance into the dash
* pattern to start the dash.<BR>
*
* @param array length of the alternating dashes and gaps
* @param phase the value of the phase
*/
public final void setLineDash(float[] array, float phase) {
content.append("[");
for (int i = 0; i < array.length; i++) {
content.append(array[i]);
if (i < array.length - 1) content.append(' ');
}
content.append("] ").append(phase).append(" d").append_i(separator);
}
/**
* Changes the <VAR>Line join style</VAR>.
* <P>
* The <VAR>line join style</VAR> specifies the shape to be used at the corners of paths
* that are stroked.<BR>
* Allowed values are LINE_JOIN_MITER (Miter joins), LINE_JOIN_ROUND (Round joins) and LINE_JOIN_BEVEL (Bevel joins).<BR>
*
* @param style a value
*/
public void setLineJoin(int style) {
if (style >= 0 && style <= 2) {
content.append(style).append(" j").append_i(separator);
}
}
/**
* Changes the <VAR>line width</VAR>.
* <P>
* The line width specifies the thickness of the line used to stroke a path and is measured
* in user space units.<BR>
*
* @param w a width
*/
public void setLineWidth(float w) {
content.append(w).append(" w").append_i(separator);
}
/**
* Changes the <VAR>Miter limit</VAR>.
* <P>
* When two line segments meet at a sharp angle and mitered joins have been specified as the
* line join style, it is possible for the miter to extend far beyond the thickness of the line
* stroking path. The miter limit imposes a maximum on the ratio of the miter length to the line
* witdh. When the limit is exceeded, the join is converted from a miter to a bevel.<BR>
*
* @param miterLimit a miter limit
*/
public void setMiterLimit(float miterLimit) {
if (miterLimit > 1) {
content.append(miterLimit).append(" M").append_i(separator);
}
}
/**
* Modify the current clipping path by intersecting it with the current path, using the
* nonzero winding number rule to determine which regions lie inside the clipping
* path.
*/
public void clip() {
content.append("W").append_i(separator);
}
/**
* Modify the current clipping path by intersecting it with the current path, using the
* even-odd rule to determine which regions lie inside the clipping path.
*/
public void eoClip() {
content.append("W*").append_i(separator);
}
/**
* Changes the currentgray tint for filling 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 filling paths.</P>
*
* @param gray a value between 0 (black) and 1 (white)
*/
public void setGrayFill(float gray) {
content.append(gray).append(" g").append_i(separator);
}
/**
* Changes the current gray tint for filling paths to black.
*/
public void resetGrayFill() {
content.append("0 g").append_i(separator);
}
/**
* 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) {
PdfXConformanceImp.checkPDFXConformance(writer, PdfXConformanceImp.PDFXKEY_RGB, null);
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 g").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 G").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êzier 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);
}
/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -