Table of Contents

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 int

the 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

int

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

bool

ZERO

public const byte ZERO = 48

Field Value

byte

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

bool

CanSeek

public override bool CanSeek { get; }

Property Value

bool

CanWrite

public override bool CanWrite { get; }

Property Value

bool

Length

public override long Length { get; }

Property Value

long

Position

public override long Position { get; set; }

Property Value

long

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

ByteBuffer

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 int

the offset to the start of the array

len int

the 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 char

the 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 double

the 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 int

the 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 float

the 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 string

the 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 ByteBuffer

the ByteBuffer to be appended

Returns

ByteBuffer

a reference to this ByteBuffer object

AppendHex(byte)

public ByteBuffer AppendHex(byte b)

Parameters

b byte

Returns

ByteBuffer

Append_i(int)

Appends an int . The size of the array will grow by one.

public ByteBuffer Append_i(int b)

Parameters

b int

the 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 double

a 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 double

a double

buf ByteBuffer

a 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

buffer byte[]
offset int
count int

Returns

int

Reset()

Sets the size to zero.

public void Reset()

Seek(long, SeekOrigin)

public override long Seek(long offset, SeekOrigin origin)

Parameters

offset long
origin SeekOrigin

Returns

long

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

buffer byte[]
offset int
count int

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 Stream

the output stream to which to write the data.