Class: FilterReader

PDFNet. FilterReader


new FilterReader()

FilterReader is a utility class providing a convenient way to read data from an input filter (using Filter directly is not very intuitive).

For example:

StdFile file("my_stream.txt", StdFile::e_read_mode);
FilterReader reader(file);
while (reader.Read(...)) ...

Methods


<static> create(filter)

Parameters:
Name Type Description
filter PDFNet.Filter
Returns:

A promise that resolves to an object of type: "FilterReader"

Type
PDFNet.FilterReader

attachFilter(filter)

Attaches a filter to the this FilterReader.

Parameters:
Name Type Description
filter PDFNet.Filter

filter object to attach


count()

Returns:

A promise that resolves to the number of bytes consumed since opening the filter or since the last Seek operation.

Type
number

destroy()

Destructor


flush()

Forces any data remaining in the buffer to be written to input or output filter.


flushAll()

Forces any data remaining in the filter chain to the source or destination.


get()

Returns:

A promise that resolves to the next character from the stream or EOF (-1) if the end of file is reached.

Type
number

getAttachedFilter()

Returns:

A promise that resolves to The attached Filter or a NULL filter if no filter is attached.

Type
PDFNet.Filter

peek()

Returns:

A promise that resolves to the next character without extracting it from the stream or or EOF (-1) if the end of file is reached.

Type
number

read(buf_size)

Read data from the attached filter

Parameters:
Name Type Description
buf_size

The maximum amount to read

Returns:

a Promise that resolves to a Uint8Array containing the data that was read. the promise will resolve to null if no data was remaining.


seek(offset, origin)

Sets the position within the current stream.

Parameters:
Name Type Description
offset number

A byte offset relative to origin. If offset is negative, the new position will precede the position specified by origin by the number of bytes specified by offset. If offset is zero, the new position will be the position specified by origin. If offset is positive, the new position will follow the position specified by origin by the number of bytes specified by offset.

origin number/enum
PDFNet.Filter.ReferencePos = {
	e_begin : 0
	e_end : 2
	e_cur : 1
}

A value of type ReferencePos indicating the reference point used to obtain the new position


tell()

Reports the current read position in the stream relative to the stream origin.

Returns:

A promise that resolves to The current position in the stream

Type
number