You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2021/01/16 12:04:54 UTC
svn commit: r1885556 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java
Author: tilman
Date: Sat Jan 16 12:04:54 2021
New Revision: 1885556
URL: http://svn.apache.org/viewvc?rev=1885556&view=rev
Log:
PDFBOX-3709: remove most deprecated methods
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java?rev=1885556&r1=1885555&r2=1885556&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java Sat Jan 16 12:04:54 2021
@@ -16,8 +16,6 @@
*/
package org.apache.pdfbox.pdmodel;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.PathIterator;
import java.io.Closeable;
import java.io.IOException;
import java.io.OutputStream;
@@ -25,18 +23,11 @@ import java.nio.charset.StandardCharsets
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.contentstream.operator.OperatorName;
import org.apache.pdfbox.cos.COSArray;
import org.apache.pdfbox.cos.COSBase;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.pdmodel.common.PDStream;
-import org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDPropertyList;
-import org.apache.pdfbox.pdmodel.graphics.PDXObject;
-import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
-import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
-import org.apache.pdfbox.pdmodel.graphics.image.PDInlineImage;
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream;
-import org.apache.pdfbox.util.Matrix;
/**
* Provides the ability to write to a page content stream.
@@ -233,532 +224,6 @@ public final class PDPageContentStream e
}
/**
- * This will draw a string at the current location on the screen.
- *
- * @param text The text to draw.
- * @throws IOException If an io exception occurs.
- * @deprecated Use {@link #showText} instead.
- */
- @Deprecated
- public void drawString(String text) throws IOException
- {
- showText(text);
- }
-
- /**
- * The Td operator.
- * A current text matrix will be replaced with a new one (1 0 0 1 x y).
- * @param tx The x translation.
- * @param ty The y translation.
- * @throws IOException If there is an error writing to the stream.
- * @deprecated Use {@link #newLineAtOffset} instead.
- */
- @Deprecated
- public void moveTextPositionByAmount(float tx, float ty) throws IOException
- {
- newLineAtOffset(tx, ty);
- }
-
- /**
- * The Tm operator. Sets the text matrix to the given values.
- * A current text matrix will be replaced with the new one.
- * @param a The a value of the matrix.
- * @param b The b value of the matrix.
- * @param c The c value of the matrix.
- * @param d The d value of the matrix.
- * @param e The e value of the matrix.
- * @param f The f value of the matrix.
- * @throws IOException If there is an error writing to the stream.
- * @deprecated Use {@link #setTextMatrix(Matrix)} instead.
- */
- @Deprecated
- public void setTextMatrix(double a, double b, double c, double d, double e, double f) throws IOException
- {
- setTextMatrix(new Matrix((float)a, (float)b, (float)c, (float)d, (float)e, (float)f));
- }
-
- /**
- * The Tm operator. Sets the text matrix to the given values.
- * A current text matrix will be replaced with the new one.
- * @param matrix the transformation matrix
- * @throws IOException If there is an error writing to the stream.
- * @deprecated Use {@link #setTextMatrix(Matrix)} instead.
- */
- @Deprecated
- public void setTextMatrix(AffineTransform matrix) throws IOException
- {
- setTextMatrix(new Matrix(matrix));
- }
-
- /**
- * The Tm operator. Sets the text matrix to the given scaling and translation values.
- * A current text matrix will be replaced with the new one.
- * @param sx The scaling factor in x-direction.
- * @param sy The scaling factor in y-direction.
- * @param tx The translation value in x-direction.
- * @param ty The translation value in y-direction.
- * @throws IOException If there is an error writing to the stream.
- * @deprecated Use {@link #setTextMatrix(Matrix)} instead.
- */
- @Deprecated
- public void setTextScaling(double sx, double sy, double tx, double ty) throws IOException
- {
- setTextMatrix(new Matrix((float) sx, 0f, 0f, (float) sy, (float) tx, (float) ty));
- }
-
- /**
- * The Tm operator. Sets the text matrix to the given translation values.
- * A current text matrix will be replaced with the new one.
- * @param tx The translation value in x-direction.
- * @param ty The translation value in y-direction.
- * @throws IOException If there is an error writing to the stream.
- * @deprecated Use {@link #setTextMatrix(Matrix)} instead.
- */
- @Deprecated
- public void setTextTranslation(double tx, double ty) throws IOException
- {
- setTextMatrix(Matrix.getTranslateInstance((float) tx, (float) ty));
- }
-
- /**
- * The Tm operator. Sets the text matrix to the given rotation and translation values.
- * A current text matrix will be replaced with the new one.
- * @param angle The angle used for the counterclockwise rotation in radians.
- * @param tx The translation value in x-direction.
- * @param ty The translation value in y-direction.
- * @throws IOException If there is an error writing to the stream.
- * @deprecated Use {@link #setTextMatrix(Matrix)} instead.
- */
- @Deprecated
- public void setTextRotation(double angle, double tx, double ty) throws IOException
- {
- setTextMatrix(Matrix.getRotateInstance(angle, (float) tx, (float) ty));
- }
-
- /**
- * Draw an inline image at the x,y coordinates, with the default size of the image.
- *
- * @param inlineImage The inline image to draw.
- * @param x The x-coordinate to draw the inline image.
- * @param y The y-coordinate to draw the inline image.
- *
- * @throws IOException If there is an error writing to the stream.
- * @deprecated Use {@link #drawImage(PDInlineImage, float, float)} instead.
- */
- @Deprecated
- public void drawInlineImage(PDInlineImage inlineImage, float x, float y) throws IOException
- {
- drawImage(inlineImage, x, y, inlineImage.getWidth(), inlineImage.getHeight());
- }
-
- /**
- * Draw an inline image at the x,y coordinates and a certain width and height.
- *
- * @param inlineImage The inline image to draw.
- * @param x The x-coordinate to draw the inline image.
- * @param y The y-coordinate to draw the inline image.
- * @param width The width of the inline image to draw.
- * @param height The height of the inline image to draw.
- *
- * @throws IOException If there is an error writing to the stream.
- * @deprecated Use {@link #drawImage(PDInlineImage, float, float, float, float)} instead.
- */
- @Deprecated
- public void drawInlineImage(PDInlineImage inlineImage, float x, float y, float width, float height) throws IOException
- {
- drawImage(inlineImage, x, y, width, height);
- }
-
- /**
- * Draw an xobject(form or image) at the x,y coordinates and a certain width and height.
- *
- * @param xobject The xobject to draw.
- * @param x The x-coordinate to draw the image.
- * @param y The y-coordinate to draw the image.
- * @param width The width of the image to draw.
- * @param height The height of the image to draw.
- *
- * @throws IOException If there is an error writing to the stream.
- * @deprecated Use {@link #drawImage} instead.
- */
- @Deprecated
- public void drawXObject(PDXObject xobject, float x, float y, float width, float height) throws IOException
- {
- AffineTransform transform = new AffineTransform(width, 0, 0, height, x, y);
- drawXObject(xobject, transform);
- }
-
- /**
- * Draw an xobject(form or image) using the given {@link AffineTransform} to position
- * the xobject.
- *
- * @param xobject The xobject to draw.
- * @param transform the transformation matrix
- * @throws IOException If there is an error writing to the stream.
- * @throws IllegalStateException If the method was called within a text block.
- * @deprecated Use {@link #drawImage(PDImageXObject, Matrix) drawImage(PDImageXObject, Matrix)}
- * or {@link #drawForm(PDFormXObject) drawForm(PDFormXObject)} with
- * {@link #transform(Matrix) transform(Matrix)} instead.
- */
- @Deprecated
- public void drawXObject(PDXObject xobject, AffineTransform transform) throws IOException
- {
- if (inTextMode)
- {
- throw new IllegalStateException("Error: drawXObject is not allowed within a text block.");
- }
-
- String xObjectPrefix;
- if (xobject instanceof PDImageXObject)
- {
- xObjectPrefix = "Im";
- }
- else
- {
- xObjectPrefix = "Form";
- }
- COSName objMapping = resources.add(xobject, xObjectPrefix);
-
- saveGraphicsState();
- transform(new Matrix(transform));
-
- writeOperand(objMapping);
- writeOperator(OperatorName.DRAW_OBJECT);
-
- restoreGraphicsState();
- }
-
- /**
- * The cm operator. Concatenates the current transformation matrix with the given values.
- * @param a The a value of the matrix.
- * @param b The b value of the matrix.
- * @param c The c value of the matrix.
- * @param d The d value of the matrix.
- * @param e The e value of the matrix.
- * @param f The f value of the matrix.
- * @throws IOException If there is an error writing to the stream.
- * @deprecated Use {@link #transform} instead.
- */
- @Deprecated
- public void concatenate2CTM(double a, double b, double c, double d, double e, double f) throws IOException
- {
- transform(new Matrix((float) a, (float) b, (float) c, (float) d, (float) e, (float) f));
- }
-
- /**
- * The cm operator. Concatenates the current transformation matrix with the given
- * {@link AffineTransform}.
- * @param at the transformation matrix
- * @throws IOException If there is an error writing to the stream.
- * @deprecated Use {@link #transform} instead.
- */
- @Deprecated
- public void concatenate2CTM(AffineTransform at) throws IOException
- {
- transform(new Matrix(at));
- }
-
- /**
- * Fill a rectangle on the page using the current non stroking color.
- *
- * @param x The lower left x coordinate.
- * @param y The lower left y coordinate.
- * @param width The width of the rectangle.
- * @param height The height of the rectangle.
- * @throws IOException If there is an error while drawing on the screen.
- * @throws IllegalStateException If the method was called within a text block.
- * @deprecated Use {@link #addRect} followed by {@link #fill()} instead.
- */
- @Deprecated
- public void fillRect(float x, float y, float width, float height) throws IOException
- {
- if (inTextMode)
- {
- throw new IllegalStateException("Error: fillRect is not allowed within a text block.");
- }
- addRect(x, y, width, height);
- fill();
- }
-
- /**
- * Append a cubic Bézier curve to the current path. The curve extends from the current
- * point to the point (x3 , y3 ), using (x1 , y1 ) and (x2 , y2 ) as the Bézier control points
- * @param x1 x coordinate of the point 1
- * @param y1 y coordinate of the point 1
- * @param x2 x coordinate of the point 2
- * @param y2 y coordinate of the point 2
- * @param x3 x coordinate of the point 3
- * @param y3 y coordinate of the point 3
- * @throws IOException If there is an error while adding the .
- * @deprecated Use {@link #curveTo} instead.
- */
- @Deprecated
- public void addBezier312(float x1, float y1, float x2, float y2, float x3, float y3) throws IOException
- {
- curveTo(x1, y1, x2, y2, x3, y3);
- }
-
- /**
- * Append a cubic Bézier curve to the current path. The curve extends from the current
- * point to the point (x3 , y3 ), using the current point and (x2 , y2 ) as the Bézier control points/
- *
- * @param x2 x coordinate of the point 2
- * @param y2 y coordinate of the point 2
- * @param x3 x coordinate of the point 3
- * @param y3 y coordinate of the point 3
- * @throws IOException If there is an error while adding the .
- * @deprecated Use {@link #curveTo2} instead.
- */
- @Deprecated
- public void addBezier32(float x2, float y2, float x3, float y3) throws IOException
- {
- curveTo2(x2, y2, x3, y3);
- }
-
- /**
- * Append a cubic Bézier curve to the current path. The curve extends from the current
- * point to the point (x3 , y3 ), using (x1 , y1 ) and (x3 , y3 ) as the Bézier control points/
- *
- * @param x1 x coordinate of the point 1
- * @param y1 y coordinate of the point 1
- * @param x3 x coordinate of the point 3
- * @param y3 y coordinate of the point 3
- * @throws IOException If there is an error while adding the .
- * @deprecated Use {@link #curveTo1} instead.
- */
- @Deprecated
- public void addBezier31(float x1, float y1, float x3, float y3) throws IOException
- {
- curveTo1(x1, y1, x3, y3);
- }
-
- /**
- * add a line to the current path.
- *
- * @param xStart The start x coordinate.
- * @param yStart The start y coordinate.
- * @param xEnd The end x coordinate.
- * @param yEnd The end y coordinate.
- * @throws IOException If there is an error while adding the line.
- * @throws IllegalStateException If the method was called within a text block.
- * @deprecated Use {@link #moveTo moveto(xStart,yStart)} followed by
- * {@link #lineTo lineTo(xEnd,yEnd)}.
- */
- @Deprecated
- public void addLine(float xStart, float yStart, float xEnd, float yEnd) throws IOException
- {
- if (inTextMode)
- {
- throw new IllegalStateException("Error: addLine is not allowed within a text block.");
- }
- moveTo(xStart, yStart);
- lineTo(xEnd, yEnd);
- }
-
- /**
- * Draw a line on the page using the current stroking color and the current line width.
- *
- * @param xStart The start x coordinate.
- * @param yStart The start y coordinate.
- * @param xEnd The end x coordinate.
- * @param yEnd The end y coordinate.
- * @throws IOException If there is an error while drawing on the screen.
- * @throws IllegalStateException If the method was called within a text block.
- * @deprecated Use {@link #moveTo moveto(xStart,yStart)} followed by
- * {@link #lineTo lineTo(xEnd,yEnd)} followed by {@link #stroke stroke()}.
- */
- @Deprecated
- public void drawLine(float xStart, float yStart, float xEnd, float yEnd) throws IOException
- {
- if (inTextMode)
- {
- throw new IllegalStateException("Error: drawLine is not allowed within a text block.");
- }
- moveTo(xStart, yStart);
- lineTo(xEnd, yEnd);
- stroke();
- }
-
- /**
- * Add a polygon to the current path.
- * @param x x coordinate of each points
- * @param y y coordinate of each points
- * @throws IOException If there is an error while drawing on the screen.
- * @throws IllegalStateException If the method was called within a text block.
- * @throws IllegalArgumentException If the two arrays have different lengths.
- * @deprecated Use {@link #moveTo} and {@link #lineTo} methods instead.
- */
- @Deprecated
- public void addPolygon(float[] x, float[] y) throws IOException
- {
- if (inTextMode)
- {
- throw new IllegalStateException("Error: addPolygon is not allowed within a text block.");
- }
- if (x.length != y.length)
- {
- throw new IllegalArgumentException("Error: some points are missing coordinate");
- }
- for (int i = 0; i < x.length; i++)
- {
- if (i == 0)
- {
- moveTo(x[i], y[i]);
- }
- else
- {
- lineTo(x[i], y[i]);
- }
- }
- closeSubPath();
- }
-
- /**
- * Draw a polygon on the page using the current stroking color.
- * @param x x coordinate of each points
- * @param y y coordinate of each points
- * @throws IOException If there is an error while drawing on the screen.
- * @throws IllegalStateException If the method was called within a text block.
- * @deprecated Use {@link #moveTo} and {@link #lineTo} methods instead.
- */
- @Deprecated
- public void drawPolygon(float[] x, float[] y) throws IOException
- {
- if (inTextMode)
- {
- throw new IllegalStateException("Error: drawPolygon is not allowed within a text block.");
- }
- addPolygon(x, y);
- stroke();
- }
-
- /**
- * Draw and fill a polygon on the page using the current stroking / non stroking colors.
- * @param x x coordinate of each points
- * @param y y coordinate of each points
- * @throws IOException If there is an error while drawing on the screen.
- * @throws IllegalStateException If the method was called within a text block.
- * @deprecated Use {@link #moveTo} and {@link #lineTo} methods instead.
- */
- @Deprecated
- public void fillPolygon(float[] x, float[] y) throws IOException
- {
- if (inTextMode)
- {
- throw new IllegalStateException("Error: fillPolygon is not allowed within a text block.");
- }
- addPolygon(x, y);
- fill();
- }
-
- /**
- * Fill the path.
- *
- * @param windingRule the winding rule to be used for filling
- * @throws IOException If the content stream could not be written
- * @throws IllegalArgumentException If the parameter is not a valid winding rule.
- * @deprecated Use {@link #fill()} or {@link #fillEvenOdd} instead.
- */
- @Deprecated
- public void fill(int windingRule) throws IOException
- {
- switch (windingRule)
- {
- case PathIterator.WIND_NON_ZERO:
- fill();
- break;
- case PathIterator.WIND_EVEN_ODD:
- fillEvenOdd();
- break;
- default:
- throw new IllegalArgumentException("Error: unknown value for winding rule");
- }
- }
-
- /**
- * Closes the current subpath.
- *
- * @throws IOException If the content stream could not be written
- * @deprecated Use {@link #closePath()} instead.
- */
- @Deprecated
- public void closeSubPath() throws IOException
- {
- closePath();
- }
-
- /**
- * Clip path.
- *
- * @param windingRule the winding rule to be used for clipping
- * @throws IOException If there is an error while clipping the path.
- * @throws IllegalStateException If the method was called within a text block.
- * @deprecated Use {@link #clip()} or {@link #clipEvenOdd} instead.
- */
- @Deprecated
- public void clipPath(int windingRule) throws IOException
- {
- if (inTextMode)
- {
- throw new IllegalStateException("Error: clipPath is not allowed within a text block.");
- }
- switch (windingRule)
- {
- case PathIterator.WIND_NON_ZERO:
- writeOperator(OperatorName.CLIP_NON_ZERO);
- break;
- case PathIterator.WIND_EVEN_ODD:
- writeOperator(OperatorName.CLIP_EVEN_ODD);
- break;
- default:
- throw new IllegalArgumentException("Error: unknown value for winding rule");
- }
- writeOperator(OperatorName.ENDPATH);
- }
-
- /**
- * Begin a marked content sequence.
- *
- * @param tag the tag
- * @throws IOException if an I/O error occurs
- * @deprecated Use {@link #beginMarkedContent} instead.
- */
- @Deprecated
- public void beginMarkedContentSequence(COSName tag) throws IOException
- {
- beginMarkedContent(tag);
- }
-
- /**
- * Begin a marked content sequence with a reference to an entry in the page resources'
- * Properties dictionary.
- *
- * @param tag the tag
- * @param propsName the properties reference
- * @throws IOException if an I/O error occurs
- * @deprecated Use {@link #beginMarkedContent(COSName, PDPropertyList)} instead.
- */
- @Deprecated
- public void beginMarkedContentSequence(COSName tag, COSName propsName) throws IOException
- {
- writeOperand(tag);
- writeOperand(propsName);
- writeOperator(OperatorName.BEGIN_MARKED_CONTENT_SEQ);
- }
-
- /**
- * End a marked content sequence.
- *
- * @throws IOException If the content stream could not be written
- * @deprecated Use {@link #endMarkedContent} instead.
- */
- @Deprecated
- public void endMarkedContentSequence() throws IOException
- {
- endMarkedContent();
- }
-
- /**
* This will append raw commands to the content stream.
*
* @param commands The commands to append to the stream.
@@ -822,17 +287,4 @@ public final class PDPageContentStream e
{
writeOperand(data);
}
-
- /**
- * This will append a {@link COSName} to the content stream.
- *
- * @param name the name
- * @throws IOException If an error occurs while writing to the stream.
- * @deprecated Usage of this method is discouraged.
- */
- @Deprecated
- public void appendCOSName(COSName name) throws IOException
- {
- writeOperand(name);
- }
}