Class ByteBuffer
- Namespace
- iTextSharp.text.pdf
- Assembly
- iTextSharp.LGPLv2.Core.dll
Acts like a StringBuilder but works with byte arrays. floating point is converted to a format suitable to the PDF. @author Paulo Soares (psoares@consiste.pt)
public class ByteBuffer : Stream, IDisposable, IAsyncDisposable
- Inheritance
-
ByteBuffer
- Implements
- Inherited Members
Constructors
ByteBuffer()
Creates new ByteBuffer with capacity 128
public ByteBuffer()
ByteBuffer(int)
Creates a byte buffer with a certain capacity.
public ByteBuffer(int size)
Parameters
size
intthe initial capacity
Fields
Buf
The buffer where the bytes are stored.
protected byte[] Buf
Field Value
- byte[]
Count
The count of bytes in the buffer.
protected int Count
Field Value
HighPrecision
If true always output floating point numbers with 6 decimal digits. If false uses the faster, although less precise, representation.
public static bool HighPrecision
Field Value
ZERO
public const byte ZERO = 48
Field Value
Properties
Buffer
Sets the cache size. This can only be used to increment the size. If the size that is passed through is smaller than the current size, nothing happens.
public byte[] Buffer { get; }
Property Value
- byte[]
CanRead
public override bool CanRead { get; }
Property Value
CanSeek
public override bool CanSeek { get; }
Property Value
CanWrite
public override bool CanWrite { get; }
Property Value
Length
public override long Length { get; }
Property Value
Position
public override long Position { get; set; }
Property Value
Size
Returns the current size of the buffer.
public int Size { get; set; }
Property Value
- int
the value of the count field, which is the number of valid bytes in this byte buffer.
Methods
Append(byte)
public ByteBuffer Append(byte b)
Parameters
b
byte
Returns
Append(byte[])
Appends an array of bytes.
public ByteBuffer Append(byte[] b)
Parameters
b
byte[]the array to be appended
Returns
- ByteBuffer
a reference to this ByteBuffer object
Append(byte[], int, int)
Appends the subarray of the byte array. The buffer will grow by len bytes.
public ByteBuffer Append(byte[] b, int off, int len)
Parameters
b
byte[]the array to be appended
off
intthe offset to the start of the array
len
intthe length of bytes to Append
Returns
- ByteBuffer
a reference to this ByteBuffer object
Append(char)
Appends a char to the buffer. The char is converted according to the encoding ISO-8859-1.
public ByteBuffer Append(char c)
Parameters
c
charthe char to be appended
Returns
- ByteBuffer
a reference to this ByteBuffer object
Append(double)
Appends a string representation of a double according to the Pdf conventions.
public ByteBuffer Append(double d)
Parameters
d
doublethe double to be appended
Returns
- ByteBuffer
a reference to this ByteBuffer object
Append(int)
Appends the string representation of an int .
public ByteBuffer Append(int i)
Parameters
i
intthe int to be appended
Returns
- ByteBuffer
a reference to this ByteBuffer object
Append(float)
Appends a string representation of a float according to the Pdf conventions.
public ByteBuffer Append(float i)
Parameters
i
floatthe float to be appended
Returns
- ByteBuffer
a reference to this ByteBuffer object
Append(string)
Appends a string to the buffer. The string is converted according to the encoding ISO-8859-1.
public ByteBuffer Append(string str)
Parameters
str
stringthe string to be appended
Returns
- ByteBuffer
a reference to this ByteBuffer object
Append(ByteBuffer)
Appends another ByteBuffer to this buffer.
public ByteBuffer Append(ByteBuffer buf)
Parameters
buf
ByteBufferthe ByteBuffer to be appended
Returns
- ByteBuffer
a reference to this ByteBuffer object
AppendHex(byte)
public ByteBuffer AppendHex(byte b)
Parameters
b
byte
Returns
Append_i(int)
Appends an int . The size of the array will grow by one.
public ByteBuffer Append_i(int b)
Parameters
b
intthe int to be appended
Returns
- ByteBuffer
a reference to this ByteBuffer object
FillCache(int)
public static void FillCache(int decimals)
Parameters
decimals
int
Flush()
public override void Flush()
FormatDouble(double)
Outputs a double into a format suitable for the PDF.
public static string FormatDouble(double d)
Parameters
d
doublea double
Returns
- string
the string representation of the double
FormatDouble(double, ByteBuffer)
Outputs a double into a format suitable for the PDF. buf is null . If buf is not null , then the double is appended directly to the buffer and this methods returns null .
public static string FormatDouble(double d, ByteBuffer buf)
Parameters
d
doublea double
buf
ByteBuffera ByteBuffer
Returns
- string
the String representation of the double if
Read(byte[], int, int)
public override int Read(byte[] buffer, int offset, int count)
Parameters
Returns
Reset()
Sets the size to zero.
public void Reset()
Seek(long, SeekOrigin)
public override long Seek(long offset, SeekOrigin origin)
Parameters
offset
longorigin
SeekOrigin
Returns
SetCacheSize(int)
public static void SetCacheSize(int size)
Parameters
size
int
SetLength(long)
public override void SetLength(long value)
Parameters
value
long
ToByteArray()
Creates a newly allocated byte array. Its size is the current size of this output stream and the valid contents of the buffer have been copied into it.
public byte[] ToByteArray()
Returns
- byte[]
the current contents of this output stream, as a byte array.
ToString()
Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding.
public override string ToString()
Returns
- string
string translated from the buffer's contents.
Write(byte[], int, int)
public override void Write(byte[] buffer, int offset, int count)
Parameters
WriteByte(byte)
public override void WriteByte(byte value)
Parameters
value
byte
WriteTo(Stream)
Writes the complete contents of this byte buffer output to the specified output stream argument, as if by calling the output stream's write method using out.Write(buf, 0, count) . @exception IOException if an I/O error occurs.
public void WriteTo(Stream str)
Parameters
str
Streamthe output stream to which to write the data.