本文整理汇总了Java中org.apache.pdfbox.cos.COSNumber类的典型用法代码示例。如果您正苦于以下问题:Java COSNumber类的具体用法?Java COSNumber怎么用?Java COSNumber使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
COSNumber类属于org.apache.pdfbox.cos包,在下文中一共展示了COSNumber类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
throws IOException {
if (arguments.size() < 6) {
throw new MissingOperandException(operator, arguments);
}
// concatenate matrix to current transformation matrix
COSNumber a = (COSNumber) arguments.get(0);
COSNumber b = (COSNumber) arguments.get(1);
COSNumber c = (COSNumber) arguments.get(2);
COSNumber d = (COSNumber) arguments.get(3);
COSNumber e = (COSNumber) arguments.get(4);
COSNumber f = (COSNumber) arguments.get(5);
Matrix matrix = new Matrix(a.floatValue(), b.floatValue(), c.floatValue(),
d.floatValue(), e.floatValue(), f.floatValue());
context.getCurrentTransformationMatrix().concatenate(matrix);
}
开发者ID:ckorzen,项目名称:icecite,代码行数:21,代码来源:ModifyCurrentTransformationMatrix.java
示例2: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
throws IOException {
COSNumber x = (COSNumber) operands.get(0);
COSNumber y = (COSNumber) operands.get(1);
COSNumber w = (COSNumber) operands.get(2);
COSNumber h = (COSNumber) operands.get(3);
Point lowerLeft = new SimplePoint(x.floatValue(), y.floatValue());
Point upperRight = new SimplePoint(w.floatValue() + lowerLeft.getX(),
h.floatValue() + lowerLeft.getY());
context.transform(lowerLeft);
context.transform(upperRight);
// To ensure that the path is created in the right direction,
// we have to create it by combining single lines instead of
// creating a simple rectangle
GeneralPath path = context.getLinePath();
path.moveTo(lowerLeft.getX(), lowerLeft.getY());
path.lineTo(upperRight.getX(), lowerLeft.getY());
path.lineTo(upperRight.getX(), upperRight.getY());
path.lineTo(lowerLeft.getX(), upperRight.getY());
path.lineTo(lowerLeft.getX(), lowerLeft.getY());
}
开发者ID:ckorzen,项目名称:icecite,代码行数:26,代码来源:AppendRectangleToPath.java
示例3: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
throws IOException {
COSNumber x2 = (COSNumber) operands.get(0);
COSNumber y2 = (COSNumber) operands.get(1);
COSNumber x3 = (COSNumber) operands.get(2);
COSNumber y3 = (COSNumber) operands.get(3);
Point2D currentPoint = context.getLinePath().getCurrentPoint();
Point point2 = new SimplePoint(x2.floatValue(), y2.floatValue());
Point point3 = new SimplePoint(x3.floatValue(), y3.floatValue());
context.transform(point2);
context.transform(point3);
if (currentPoint == null) {
context.getLinePath().moveTo(point3.getX(), point3.getY());
} else {
context.getLinePath().curveTo(
(float) currentPoint.getX(), (float) currentPoint.getY(),
point2.getX(), point2.getY(), point3.getX(), point3.getY());
}
}
开发者ID:ckorzen,项目名称:icecite,代码行数:24,代码来源:CurveToReplicateInitialPoint.java
示例4: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
throws IOException {
COSNumber x1 = (COSNumber) operands.get(0);
COSNumber y1 = (COSNumber) operands.get(1);
COSNumber x3 = (COSNumber) operands.get(2);
COSNumber y3 = (COSNumber) operands.get(3);
Point point1 = new SimplePoint(x1.floatValue(), y1.floatValue());
Point point3 = new SimplePoint(x3.floatValue(), y3.floatValue());
context.transform(point1);
context.transform(point3);
context.getLinePath().curveTo(point1.getX(), point1.getY(),
point3.getX(), point3.getY(), point3.getX(), point3.getY());
}
开发者ID:ckorzen,项目名称:icecite,代码行数:18,代码来源:CurveToReplicateFinalPoint.java
示例5: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
throws IOException {
COSNumber x1 = (COSNumber) operands.get(0);
COSNumber y1 = (COSNumber) operands.get(1);
COSNumber x2 = (COSNumber) operands.get(2);
COSNumber y2 = (COSNumber) operands.get(3);
COSNumber x3 = (COSNumber) operands.get(4);
COSNumber y3 = (COSNumber) operands.get(5);
Point point1 = new SimplePoint(x1.floatValue(), y1.floatValue());
Point point2 = new SimplePoint(x2.floatValue(), y2.floatValue());
Point point3 = new SimplePoint(x3.floatValue(), y3.floatValue());
context.transform(point1);
context.transform(point2);
context.transform(point3);
if (context.getLinePath().getCurrentPoint() == null) {
context.getLinePath().moveTo(point3.getX(), point3.getY());
} else {
context.getLinePath().curveTo(point1.getX(), point1.getY(),
point2.getX(), point2.getY(), point3.getX(), point3.getY());
}
}
开发者ID:ckorzen,项目名称:icecite,代码行数:26,代码来源:CurveTo.java
示例6: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
throws MissingOperandException {
if (arguments.size() < 6) {
throw new MissingOperandException(operator, arguments);
}
COSNumber a = (COSNumber) arguments.get(0);
COSNumber b = (COSNumber) arguments.get(1);
COSNumber c = (COSNumber) arguments.get(2);
COSNumber d = (COSNumber) arguments.get(3);
COSNumber e = (COSNumber) arguments.get(4);
COSNumber f = (COSNumber) arguments.get(5);
// Set both matrices to
// [ a b 0
// c d 0
// e f 1 ]
Matrix matrix = new Matrix(a.floatValue(), b.floatValue(),
c.floatValue(), d.floatValue(), e.floatValue(), f.floatValue());
context.setTextMatrix(matrix);
context.setTextLineMatrix(matrix.clone());
}
开发者ID:ckorzen,项目名称:icecite,代码行数:26,代码来源:SetTextMatrix.java
示例7: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
throws MissingOperandException {
if (arguments.size() < 2) {
throw new MissingOperandException(operator, arguments);
}
Matrix tlm = context.getTextLineMatrix();
if (tlm == null) {
return;
}
COSNumber tx = (COSNumber) arguments.get(0);
COSNumber ty = (COSNumber) arguments.get(1);
Matrix matrix = new Matrix(1, 0, 0, 1, tx.floatValue(), ty.floatValue());
tlm.concatenate(matrix);
context.setTextMatrix(tlm.clone());
}
开发者ID:ckorzen,项目名称:icecite,代码行数:20,代码来源:MoveText.java
示例8: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands) throws IOException {
if (operands.size() < 4) {
throw new MissingOperandException(operator, operands);
}
if (!checkArrayTypesClass(operands, COSNumber.class)) {
return;
}
COSNumber x = (COSNumber) operands.get(0);
COSNumber y = (COSNumber) operands.get(1);
COSNumber w = (COSNumber) operands.get(2);
COSNumber h = (COSNumber) operands.get(3);
float x1 = x.floatValue();
float y1 = y.floatValue();
// create a pair of coordinates for the transformation
float x2 = w.floatValue() + x1;
float y2 = h.floatValue() + y1;
Point2D p0 = context.transformedPoint(x1, y1);
Point2D p1 = context.transformedPoint(x2, y1);
Point2D p2 = context.transformedPoint(x2, y2);
Point2D p3 = context.transformedPoint(x1, y2);
// to ensure that the path is created in the right direction, we have to create
// it by combining single lines instead of creating a simple rectangle
linePath.moveTo((float) p0.getX(), (float) p0.getY());
linePath.lineTo((float) p1.getX(), (float) p1.getY());
linePath.lineTo((float) p2.getX(), (float) p2.getY());
linePath.lineTo((float) p3.getX(), (float) p3.getY());
// close the subpath instead of adding the last line so that a possible set line
// cap style isn't taken into account at the "beginning" of the rectangle
linePath.closePath();
}
开发者ID:mkl-public,项目名称:testarea-pdfbox2,代码行数:37,代码来源:PDFVisibleTextStripper.java
示例9: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
throws IOException {
// append straight line segment from the current point to the point.
COSNumber x = (COSNumber) operands.get(0);
COSNumber y = (COSNumber) operands.get(1);
Point point = new SimplePoint(x.floatValue(), y.floatValue());
context.transform(point);
context.getLinePath().lineTo(point.getX(), point.getY());
}
开发者ID:ckorzen,项目名称:icecite,代码行数:13,代码来源:LineTo.java
示例10: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
throws IOException {
COSNumber x = (COSNumber) operands.get(0);
COSNumber y = (COSNumber) operands.get(1);
Point point = new SimplePoint(x.floatValue(), y.floatValue());
context.transform(point);
context.getLinePath().moveTo(point.getX(), point.getY());
}
开发者ID:ckorzen,项目名称:icecite,代码行数:12,代码来源:MoveTo.java
示例11: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
throws IOException {
if (arguments.size() < 6) {
throw new MissingOperandException(operator, arguments);
}
// Set glyph with and bounding box for type 3 font
// COSNumber hDisplacement = (COSNumber) arguments.get(0);
// COSNumber vDisplacement = (COSNumber) arguments.get(1);
COSNumber llx = (COSNumber) arguments.get(2);
COSNumber lly = (COSNumber) arguments.get(3);
COSNumber urx = (COSNumber) arguments.get(4);
COSNumber ury = (COSNumber) arguments.get(5);
Point lowerLeft = new SimplePoint(llx.floatValue(), lly.floatValue());
Point upperRight = new SimplePoint(urx.floatValue(), ury.floatValue());
context.transform(lowerLeft);
context.transform(upperRight);
float minX = Math.min(lowerLeft.getX(), upperRight.getX());
float minY = Math.min(lowerLeft.getY(), upperRight.getY());
float maxX = Math.max(lowerLeft.getX(), upperRight.getX());
float maxY = Math.max(lowerLeft.getY(), upperRight.getY());
Rectangle boundingBox = new SimpleRectangle(minX, minY, maxX, maxY);
context.setCurrentType3GlyphBoundingBox(boundingBox);
}
开发者ID:ckorzen,项目名称:icecite,代码行数:30,代码来源:SetType3GlyphWidthAndBoundingBox.java
示例12: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
throws IOException {
if (arguments.isEmpty()) {
throw new MissingOperandException(operator, arguments);
}
// there are some documents which are incorrectly structured, and have
// a wrong number of arguments to this, so we will assume the last argument
// in the list
Object charSpacing = arguments.get(arguments.size() - 1);
if (charSpacing instanceof COSNumber) {
COSNumber characterSpacing = (COSNumber) charSpacing;
PDTextState textState = context.getGraphicsState().getTextState();
textState.setCharacterSpacing(characterSpacing.floatValue());
}
}
开发者ID:ckorzen,项目名称:icecite,代码行数:18,代码来源:SetCharacterSpacing.java
示例13: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
throws IOException {
if (arguments.isEmpty()) {
throw new MissingOperandException(operator, arguments);
}
PDTextState textState = context.getGraphicsState().getTextState();
float fontSize = textState.getFontSize();
float horizontalScaling = textState.getHorizontalScaling() / 100f;
boolean isVertical = textState.getFont().isVertical();
COSArray array = (COSArray) arguments.get(0);
for (COSBase obj : array) {
if (obj instanceof COSNumber) {
float tj = ((COSNumber) obj).floatValue();
// calculate the combined displacements
float tx, ty;
if (isVertical) {
tx = 0;
ty = -tj / 1000 * fontSize;
} else {
tx = -tj / 1000 * fontSize * horizontalScaling;
ty = 0;
}
Matrix translate = Matrix.getTranslateInstance(tx, ty);
context.getTextMatrix().concatenate(translate);
} else if (obj instanceof COSString) {
List<COSBase> args = new ArrayList<COSBase>();
args.add(obj);
context.processOperator("Tj", args);
} else {
throw new IOException("Unknown type in array for TJ operation:" + obj);
}
}
}
开发者ID:ckorzen,项目名称:icecite,代码行数:39,代码来源:ShowTextWithIndividualGlyphPositioning.java
示例14: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
public void process(PDFOperator operator, List<COSBase> arguments)
{
COSNumber x = (COSNumber) arguments.get(0);
COSNumber y = (COSNumber) arguments.get(1);
COSNumber w = (COSNumber) arguments.get(2);
COSNumber h = (COSNumber) arguments.get(3);
double x1 = x.doubleValue();
double y1 = y.doubleValue();
// create a pair of coordinates for the transformation
double x2 = w.doubleValue() + x1;
double y2 = h.doubleValue() + y1;
Point2D p0 = transformedPoint(x1, y1);
Point2D p1 = transformedPoint(x2, y1);
Point2D p2 = transformedPoint(x2, y2);
Point2D p3 = transformedPoint(x1, y2);
rectangles.add(new TransformedRectangle(p0, p1, p2, p3));
}
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:22,代码来源:PDFStyledTextStripper.java
示例15: intValue
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
/**
* Obtains a number from a PDF number value
* @param value the PDF value of the Integer or Fload type
* @return the corresponging numeric value
*/
protected int intValue(COSBase value)
{
if (value instanceof COSNumber)
return ((COSNumber) value).intValue();
else
return 0;
}
开发者ID:radkovo,项目名称:Pdf2Dom,代码行数:13,代码来源:PDFBoxTree.java
示例16: floatValue
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
/**
* Obtains a number from a PDF number value
* @param value the PDF value of the Integer or Float type
* @return the corresponging numeric value
*/
protected float floatValue(COSBase value)
{
if (value instanceof COSNumber)
return ((COSNumber) value).floatValue();
else
return 0;
}
开发者ID:radkovo,项目名称:Pdf2Dom,代码行数:13,代码来源:PDFBoxTree.java
示例17: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
/**
* TJ Show text, allowing individual glyph positioning.
* @param operator The operator that is being executed.
* @param arguments List
* @throws IOException If there is an error processing this operator.
*/
public void process(PDFOperator operator, List arguments) throws IOException
{
((PDFObjectExtractor)context).setNewTextFragment(true);
COSArray array = (COSArray)arguments.get( 0 );
float adjustment=0;
for( int i=0; i<array.size(); i++ )
{
COSBase next = array.get( i );
if( next instanceof COSNumber )
{
adjustment = ((COSNumber)next).floatValue();
Matrix adjMatrix = new Matrix();
adjustment=(-adjustment/1000)*context.getGraphicsState().getTextState().getFontSize() *
(context.getGraphicsState().getTextState().getHorizontalScalingPercent()/100);
adjMatrix.setValue( 2, 0, adjustment );
context.setTextMatrix( adjMatrix.multiply( context.getTextMatrix() ) );
}
else if( next instanceof COSString )
{
// TEST 27.08.09
// ((PDFObjectExtractor)context).setNewTextFragment(true);
((PDFObjectExtractor)context).showString( ((COSString)next).getBytes() , i);
//((PDFObjectExtractor)context).setNewTextFragment(false);
// automatically set in addCharacter method (simplest way possible)
}
else
{
throw new IOException( "Unknown type in array for TJ operation:" + next );
}
}
}
开发者ID:tamirhassan,项目名称:pdfxtk,代码行数:40,代码来源:ShowTextGlyph.java
示例18: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
/**
* process : l : Append straight line segment to path.
* @param operator The operator that is being executed.
* @param arguments List
*/
public void process(PDFOperator operator, List arguments)
{
PDFObjectExtractor drawer = (PDFObjectExtractor)context;
//append straight line segment from the current point to the point.
COSNumber x = (COSNumber)arguments.get( 0 );
COSNumber y = (COSNumber)arguments.get( 1 );
//drawer.getLinePath().lineTo( x.floatValue(), (float)drawer.fixY( x.doubleValue(), y.doubleValue()) );
Point2D Ppos = drawer.TransformedPoint(x.doubleValue(), y.doubleValue());
drawer.getLinePath().lineTo((float)Ppos.getX(), (float)Ppos.getY());
////drawer.simpleLineTo((float)Ppos.getX(), (float)Ppos.getY());
drawer.simpleLineTo(x.floatValue(), y.floatValue());
}
开发者ID:tamirhassan,项目名称:pdfxtk,代码行数:21,代码来源:LineTo.java
示例19: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
/**
* process : y : Append curved segment to path (final point replicated).
* @param operator The operator that is being executed.
* @param arguments List
*/
public void process(PDFOperator operator, List arguments)
{
PDFObjectExtractor drawer = (PDFObjectExtractor)context;
COSNumber x1 = (COSNumber)arguments.get( 0 );
COSNumber y1 = (COSNumber)arguments.get( 1 );
COSNumber x3 = (COSNumber)arguments.get( 2 );
COSNumber y3 = (COSNumber)arguments.get( 3 );
/*float x1f = x1.floatValue();
float y1f = (float)drawer.fixY( x1f, y1.floatValue() );
float x3f = x3.floatValue();
float y3f = (float)drawer.fixY( x3f, y3.floatValue() );
drawer.getLinePath().curveTo(x1f,y1f,x3f,y3f,x3f,y3f);
*/
Point2D P1 = drawer.TransformedPoint(x1.doubleValue(), y1.doubleValue());
Point2D P3 = drawer.TransformedPoint(x3.doubleValue(), y3.doubleValue());
drawer.getLinePath().curveTo((float)P1.getX(), (float)P1.getY(), (float)P3.getX(), (float)P3.getY(), (float)P3.getX(), (float)P3.getY());
drawer.simpleCurveTo((float)P1.getX(), (float)P1.getY(), (float)P3.getX(), (float)P3.getY(), (float)P3.getX(), (float)P3.getY());
}
开发者ID:tamirhassan,项目名称:pdfxtk,代码行数:27,代码来源:CurveToReplicateFinalPoint.java
示例20: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
/**
* process : c : Append curved segment to path.
* @param operator The operator that is being executed.
* @param arguments List
*/
public void process(PDFOperator operator, List arguments)
{
PDFObjectExtractor drawer = (PDFObjectExtractor)context;
COSNumber x1 = (COSNumber)arguments.get( 0 );
COSNumber y1 = (COSNumber)arguments.get( 1 );
COSNumber x2 = (COSNumber)arguments.get( 2 );
COSNumber y2 = (COSNumber)arguments.get( 3 );
COSNumber x3 = (COSNumber)arguments.get( 4 );
COSNumber y3 = (COSNumber)arguments.get( 5 );
/* float x1f = x1.floatValue();
float y1f = (float)drawer.fixY( x1f, y1.floatValue() );
float x2f = x2.floatValue();
float y2f = (float)drawer.fixY( x2f, y2.floatValue() );
float x3f = x3.floatValue();
float y3f = (float)drawer.fixY( x3f, y3.floatValue() );
drawer.getLinePath().curveTo(x1f,y1f,x2f,y2f,x3f,y3f);
*/
Point2D P1 = drawer.TransformedPoint(x1.doubleValue(), y1.doubleValue());
Point2D P2 = drawer.TransformedPoint(x2.doubleValue(), y2.doubleValue());
Point2D P3 = drawer.TransformedPoint(x3.doubleValue(), y3.doubleValue());
drawer.getLinePath().curveTo((float)P1.getX(), (float)P1.getY(), (float)P2.getX(), (float)P2.getY(), (float)P3.getX(), (float)P3.getY());
drawer.simpleCurveTo((float)P1.getX(), (float)P1.getY(), (float)P2.getX(), (float)P2.getY(), (float)P3.getX(), (float)P3.getY());
}
开发者ID:tamirhassan,项目名称:pdfxtk,代码行数:31,代码来源:CurveTo.java
注:本文中的org.apache.pdfbox.cos.COSNumber类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论