org.apache.fop.pdf

## Class PDFNumber

- java.lang.Object
- - org.apache.fop.pdf.PDFObject
  - - org.apache.fop.pdf.PDFNumber

- All Implemented Interfaces:
    PDFWritable

      public class PDFNumber
      extends PDFObject

  This class represents a simple number object. It also contains contains some utility methods for outputting numbers to PDF.

- - ### Field Summary

    - ### Fields inherited from class org.apache.fop.pdf.PDFObject

      `log`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PDFNumber()`
    `PDFNumber(Number number)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `doubleOut(double doubleDown)` Output a double value to a string suitable for PDF (6 decimal digits).
    `static String` | `doubleOut(Double doubleDown)` Output a Double value to a string suitable for PDF.
    `static String` | `doubleOut(double doubleDown, int dec)` Output a double value to a string suitable for PDF.
    `static StringBuffer` | `doubleOut(double doubleDown, int dec, StringBuffer buf)` Append a double value to a string buffer suitable for PDF.
    `Number` | `getNumber()` Returns the number.
    `void` | `setNumber(Number number)` Sets the number.
    `boolean` | `supportsObjectStream()`
    `protected String` | `toPDFString()` This method returns a String representation of the PDF object.

    - ### Methods inherited from class org.apache.fop.pdf.PDFObject

      `contentEquals, encode, encodeBinaryToHexString, encodeString, encodeText, formatObject, getChildren, getDocument, getDocumentSafely, getGeneration, getObjectID, getObjectNumber, getParent, hasObjectNumber, makeReference, output, outputInline, referencePDF, setDocument, setObjectNumber, setObjectNumber, setObjectNumber, setParent, toPDF`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PDFNumber

          public PDFNumber()

    - #### PDFNumber

          public PDFNumber(Number number)

  - ### Method Detail

    - #### getNumber

          public Number getNumber()

      Returns the number.
      Returns:
        the number

    - #### setNumber

          public void setNumber(Number number)

      Sets the number.
      Parameters:
        `number` - the number

    - #### doubleOut

          public static String doubleOut(Double doubleDown)

      Output a Double value to a string suitable for PDF.
      Parameters:
        `doubleDown` - the Double value
      Returns:
        the value as a string

    - #### doubleOut

          public static String doubleOut(double doubleDown)

      Output a double value to a string suitable for PDF (6 decimal digits).
      Parameters:
        `doubleDown` - the double value
      Returns:
        the value as a string

    - #### doubleOut

          public static String doubleOut(double doubleDown,
                                         int dec)

      Output a double value to a string suitable for PDF. In this method it is possible to set the maximum number of decimal places to output.
      Parameters:
        `doubleDown` - the Double value
        `dec` - the number of decimal places to output
      Returns:
        the value as a string

    - #### doubleOut

          public static StringBuffer doubleOut(double doubleDown,
                                               int dec,
                                               StringBuffer buf)

      Append a double value to a string buffer suitable for PDF. In this method it is possible to set the maximum number of decimal places to output.
      Parameters:
        `doubleDown` - the Double value
        `dec` - the number of decimal places to output
        `buf` - the string buffer to which double is formatted (appended)
      Returns:
        the string buffer

    - #### toPDFString

          protected String toPDFString()

      This method returns a String representation of the PDF object. The result is normally converted/encoded to a byte array by toPDF(). Only use this method to implement the serialization if the object can be fully represented as text. If the PDF representation of the object contains binary content use toPDF() or output(OutputStream) instead. This applies to any object potentially containing a string object because string object are encrypted and therefore need to be binary.
      Overrides:
        `toPDFString` in class `PDFObject`
      Returns:
        String the String representation

    - #### supportsObjectStream

          public boolean supportsObjectStream()

      Overrides:
        `supportsObjectStream` in class `PDFObject`

Copyright © 2025 Apache Software Foundation. All rights reserved.