org.apache.pdfbox.cos.COSFloat Java Examples
The following examples show how to use
org.apache.pdfbox.cos.COSFloat.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MoveTextSetLeading.java From gcs with Mozilla Public License 2.0 | 6 votes |
@Override public void process(Operator operator, List<COSBase> arguments) throws IOException { if (arguments.size() < 2) { throw new MissingOperandException(operator, arguments); } //move text position and set leading COSBase base1 = arguments.get(1); if (!(base1 instanceof COSNumber)) { return; } COSNumber y = (COSNumber) base1; List<COSBase> args = new ArrayList<COSBase>(); args.add(new COSFloat(-1 * y.floatValue())); context.processOperator(OperatorName.SET_TEXT_LEADING, args); context.processOperator(OperatorName.MOVE_TEXT, arguments); }
Example #2
Source File: PDLab.java From gcs with Mozilla Public License 2.0 | 6 votes |
private void setComponentRangeArray(PDRange range, int index) { COSArray rangeArray = (COSArray) dictionary.getDictionaryObject(COSName.RANGE); if (rangeArray == null) { rangeArray = getDefaultRangeArray(); } if (range == null) { // reset to defaults rangeArray.set(index, new COSFloat(-100)); rangeArray.set(index + 1, new COSFloat(100)); } else { rangeArray.set(index, new COSFloat(range.getMin())); rangeArray.set(index + 1, new COSFloat(range.getMax())); } dictionary.setItem(COSName.RANGE, rangeArray); initialColor = null; }
Example #3
Source File: PDRectangle.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Constructor. * * @param x the x coordinate of the rectangle * @param y the y coordinate of the rectangle * @param width The width of the rectangle. * @param height The height of the rectangle. */ public PDRectangle( float x, float y, float width, float height ) { rectArray = new COSArray(); rectArray.add( new COSFloat( x ) ); rectArray.add( new COSFloat( y ) ); rectArray.add( new COSFloat( x + width ) ); rectArray.add( new COSFloat( y + height ) ); }
Example #4
Source File: CompatibilityHelper.java From pdfbox-layout with MIT License | 5 votes |
private static PDGamma toPDGamma(final Color color) { COSArray values = new COSArray(); values.add(new COSFloat(color.getRed() / 255f)); values.add(new COSFloat(color.getGreen() / 255f)); values.add(new COSFloat(color.getBlue() / 255f)); return new PDGamma(values); }
Example #5
Source File: NextLine.java From gcs with Mozilla Public License 2.0 | 5 votes |
@Override public void process(Operator operator, List<COSBase> arguments) throws IOException { //move to start of next text line List<COSBase> args = new ArrayList<COSBase>(); args.add(new COSFloat(0f)); // this must be -leading instead of just leading as written in the // specification (p.369) the acrobat reader seems to implement it the same way args.add(new COSFloat(-1 * context.getGraphicsState().getTextState().getLeading())); // use Td instead of repeating code context.processOperator(OperatorName.MOVE_TEXT, args); }
Example #6
Source File: Matrix.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Returns a COS array which represents this matrix. */ public COSArray toCOSArray() { COSArray array = new COSArray(); array.add(new COSFloat(single[0])); array.add(new COSFloat(single[1])); array.add(new COSFloat(single[3])); array.add(new COSFloat(single[4])); array.add(new COSFloat(single[6])); array.add(new COSFloat(single[7])); return array; }
Example #7
Source File: PDPageXYZDestination.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Set the zoom value for the page, values 0 or -1 imply that the current zoom * will be used. * @param zoom The zoom value. */ public void setZoom( float zoom ) { array.growToSize( 5 ); if( zoom == -1 ) { array.set(4, null); } else { array.set( 4, new COSFloat(zoom) ); } }
Example #8
Source File: PDOutlineItem.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Set the RGB text color for this node. * * @param textColor The text color for this node. */ public void setTextColor( Color textColor ) { COSArray array = new COSArray(); array.add( new COSFloat( textColor.getRed()/255f)); array.add( new COSFloat( textColor.getGreen()/255f)); array.add( new COSFloat( textColor.getBlue()/255f)); getCOSObject().setItem( COSName.C, array ); }
Example #9
Source File: PDRange.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Constructor with an initial range of 0..1. */ public PDRange() { rangeArray = new COSArray(); rangeArray.add( new COSFloat( 0.0f ) ); rangeArray.add( new COSFloat( 1.0f ) ); startingIndex = 0; }
Example #10
Source File: PDRectangle.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Constructor. * * @param array An array of numbers as specified in the PDF Reference for a rectangle type. */ public PDRectangle( COSArray array ) { float[] values = Arrays.copyOf(array.toFloatArray(), 4); rectArray = new COSArray(); // we have to start with the lower left corner rectArray.add( new COSFloat( Math.min(values[0],values[2] )) ); rectArray.add( new COSFloat( Math.min(values[1],values[3] )) ); rectArray.add( new COSFloat( Math.max(values[0],values[2] )) ); rectArray.add( new COSFloat( Math.max(values[1],values[3] )) ); }
Example #11
Source File: PDRectangle.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Constructor. * * @param box the bounding box to be used for the rectangle */ public PDRectangle( BoundingBox box ) { rectArray = new COSArray(); rectArray.add( new COSFloat( box.getLowerLeftX() ) ); rectArray.add( new COSFloat( box.getLowerLeftY() ) ); rectArray.add( new COSFloat( box.getUpperRightX() ) ); rectArray.add( new COSFloat( box.getUpperRightY() ) ); }
Example #12
Source File: PDStandardAttributeObject.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Sets an array of float numbers. * * @param name the attribute name * @param values the float numbers */ protected void setArrayOfNumber(String name, float[] values) { COSArray array = new COSArray(); for (float value : values) { array.add(new COSFloat(value)); } COSBase oldBase = this.getCOSObject().getDictionaryObject(name); this.getCOSObject().setItem(name, array); COSBase newBase = this.getCOSObject().getDictionaryObject(name); this.potentiallyNotifyChanged(oldBase, newBase); }
Example #13
Source File: PDGamma.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Creates a new gamma. * Defaults all values to 0, 0, 0. */ public PDGamma() { values = new COSArray(); values.add(new COSFloat(0.0f)); values.add(new COSFloat(0.0f)); values.add(new COSFloat(0.0f)); }
Example #14
Source File: PDShadingType1.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Sets the optional Matrix entry for the function based shading. * * @param transform the transformation matrix */ public void setMatrix(AffineTransform transform) { COSArray matrix = new COSArray(); double[] values = new double[6]; transform.getMatrix(values); for (double v : values) { matrix.add(new COSFloat((float) v)); } getCOSObject().setItem(COSName.MATRIX, matrix); }
Example #15
Source File: PDFontSetting.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Creates a blank font setting, font will be null, size will be 1. */ public PDFontSetting() { fontSetting = new COSArray(); fontSetting.add( null ); fontSetting.add( new COSFloat( 1 ) ); }
Example #16
Source File: PDFormXObject.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Sets the optional Matrix entry for the form XObject. * @param transform the transformation matrix */ public void setMatrix(AffineTransform transform) { COSArray matrix = new COSArray(); double[] values = new double[6]; transform.getMatrix(values); for (double v : values) { matrix.add(new COSFloat((float) v)); } getCOSObject().setItem(COSName.MATRIX, matrix); }
Example #17
Source File: PDTristimulus.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Constructor from COS object. * @param array the array containing the XYZ values */ public PDTristimulus(float[] array) { values = new COSArray(); for(int i=0; i<array.length && i<3; i++) { values.add(new COSFloat(array[i])); } }
Example #18
Source File: PDAbstractPattern.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Sets the optional Matrix entry for the Pattern. * @param transform the transformation matrix */ public void setMatrix(AffineTransform transform) { COSArray matrix = new COSArray(); double[] values = new double[6]; transform.getMatrix(values); for (double v : values) { matrix.add(new COSFloat((float)v)); } getCOSObject().setItem(COSName.MATRIX, matrix); }
Example #19
Source File: PDTristimulus.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Constructor. Defaults all values to 0, 0, 0. */ public PDTristimulus() { values = new COSArray(); values.add(new COSFloat(0.0f)); values.add(new COSFloat(0.0f)); values.add(new COSFloat(0.0f)); }
Example #20
Source File: PDLab.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * creates a range array with default values (-100..100 -100..100). * @return the new range array. */ private COSArray getDefaultRangeArray() { COSArray range = new COSArray(); range.add(new COSFloat(-100)); range.add(new COSFloat(100)); range.add(new COSFloat(-100)); range.add(new COSFloat(100)); return range; }
Example #21
Source File: PDExtendedGraphicsState.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * This will set a float object. * * @param key The key to the data that we are setting. * @param value The value that we are setting. */ private void setFloatItem( COSName key, Float value ) { if( value == null ) { dict.removeItem(key); } else { dict.setItem(key, new COSFloat(value)); } }
Example #22
Source File: PDTristimulus.java From gcs with Mozilla Public License 2.0 | 4 votes |
/** * Sets the z value of the tristimulus. * @param z the z value for the tristimulus */ public void setZ(float z) { values.set(2, new COSFloat(z)); }
Example #23
Source File: ContentStreamWriter.java From gcs with Mozilla Public License 2.0 | 4 votes |
private void writeObject( Object o ) throws IOException { if( o instanceof COSString ) { COSWriter.writeString((COSString)o, output); output.write( SPACE ); } else if( o instanceof COSFloat ) { ((COSFloat)o).writePDF( output ); output.write( SPACE ); } else if( o instanceof COSInteger ) { ((COSInteger)o).writePDF( output ); output.write( SPACE ); } else if( o instanceof COSBoolean ) { ((COSBoolean)o).writePDF( output ); output.write( SPACE ); } else if( o instanceof COSName ) { ((COSName)o).writePDF( output ); output.write( SPACE ); } else if( o instanceof COSArray ) { COSArray array = (COSArray)o; output.write(COSWriter.ARRAY_OPEN); for( int i=0; i<array.size(); i++ ) { writeObject( array.get( i ) ); output.write( SPACE ); } output.write( COSWriter.ARRAY_CLOSE ); } else if( o instanceof COSDictionary ) { COSDictionary obj = (COSDictionary)o; output.write( COSWriter.DICT_OPEN ); for (Map.Entry<COSName, COSBase> entry : obj.entrySet()) { if (entry.getValue() != null) { writeObject( entry.getKey() ); output.write( SPACE ); writeObject( entry.getValue() ); output.write( SPACE ); } } output.write( COSWriter.DICT_CLOSE ); output.write( SPACE ); } else if( o instanceof Operator) { Operator op = (Operator)o; if (op.getName().equals(OperatorName.BEGIN_INLINE_IMAGE)) { output.write(OperatorName.BEGIN_INLINE_IMAGE.getBytes(Charsets.ISO_8859_1)); COSDictionary dic = op.getImageParameters(); for( COSName key : dic.keySet() ) { Object value = dic.getDictionaryObject( key ); key.writePDF( output ); output.write( SPACE ); writeObject( value ); output.write( EOL ); } output.write(OperatorName.BEGIN_INLINE_IMAGE_DATA.getBytes(Charsets.ISO_8859_1)); output.write( EOL ); output.write( op.getImageData() ); output.write( EOL ); output.write(OperatorName.END_INLINE_IMAGE.getBytes(Charsets.ISO_8859_1)); output.write( EOL ); } else { output.write( op.getName().getBytes(Charsets.ISO_8859_1) ); output.write( EOL ); } } else { throw new IOException( "Error:Unknown type in content stream:" + o ); } }
Example #24
Source File: COSWriter.java From gcs with Mozilla Public License 2.0 | 4 votes |
@Override public Object visitFromFloat(COSFloat obj) throws IOException { obj.writePDF( getStandardOutput() ); return null; }
Example #25
Source File: PDTransition.java From gcs with Mozilla Public License 2.0 | 4 votes |
/** * @param scale The starting or ending scale at which the changes shall be drawn. Only for * {@link PDTransitionStyle#Fly}. */ public void setFlyScale(float scale) { getCOSObject().setItem(COSName.SS, new COSFloat(scale)); }
Example #26
Source File: PDTransition.java From gcs with Mozilla Public License 2.0 | 4 votes |
/** * @param duration The duration of the transition effect, in seconds. */ public void setDuration(float duration) { getCOSObject().setItem(COSName.D, new COSFloat(duration)); }
Example #27
Source File: PDTristimulus.java From gcs with Mozilla Public License 2.0 | 4 votes |
/** * Sets the y value of the tristimulus. * @param y the y value for the tristimulus */ public void setY(float y) { values.set(1, new COSFloat(y)); }
Example #28
Source File: PDTristimulus.java From gcs with Mozilla Public License 2.0 | 4 votes |
/** * Sets the x value of the tristimulus. * @param x the x value for the tristimulus */ public void setX(float x) { values.set(0, new COSFloat(x)); }
Example #29
Source File: PDGamma.java From gcs with Mozilla Public License 2.0 | 4 votes |
/** * Sets the r value of the tristimulus. * @param r the r value for the tristimulus */ public void setR(float r) { values.set(0, new COSFloat(r)); }
Example #30
Source File: PDGamma.java From gcs with Mozilla Public License 2.0 | 4 votes |
/** * Sets the g value of the tristimulus. * @param g the g value for the tristimulus */ public void setG(float g) { values.set(1, new COSFloat(g)); }