Class: FilterWriter

PDFNet. FilterWriter


new FilterWriter()

FilterWriter is a utility class providing a convenient way to write data to an output filter (using Filter directly is not very intuitive).

For example:

StdFile outfile("file.dat", StdFile::e_write_mode);
FilterWriter fwriter(outfile);
fwriter.WriteBuffer(buf, buf_sz);
fwriter.Flush();

Methods


<static> create(filter)

Constructor

Parameters:
Name Type Description
filter PDFNet.Filter
Returns:

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

Type
PDFNet.FilterWriter

attachFilter(filter)

Attaches a filter to the this FilterWriter.

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.


getAttachedFilter()

Returns:

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

Type
PDFNet.Filter

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

writeBuffer(buf)

Parameters:
Name Type Description
buf Array

buffer object to write out.

Returns:

A promise that resolves to returns the number of bytes actually written to a stream. This number may less than buf_size if the stream is corrupted.

Type
number

writeFilter(reader)

Write the entire input stream to the output stream (i.e. to this FilterWriter).

Parameters:
Name Type Description
reader PDFNet.FilterReader

A FilterReader attached to an input stream.


writeInt16(num)

Write an integer to the output stream.

Parameters:
Name Type Description
num number

An integer to write to the output stream.


writeInt32(num)

Write an integer to the output stream.

Parameters:
Name Type Description
num number

An integer to write to the output stream.


writeInt64(num)

Write an integer to the output stream.

Parameters:
Name Type Description
num number

An integer to write to the output stream.


writeLine(line, eol)

Write out a null terminated 'line' followed by a end of line character default end of line character is carriage return.

Parameters:
Name Type Description
line string

string to write out.

eol number

end of line character. Defaults to carriage return (0x0D).


writeString(str)

Write a string to the output stream.

Parameters:
Name Type Description
str string

A string to write to the output stream.


writeUChar(ch)

Write a single character to the output stream.

Parameters:
Name Type Description
ch number

An unsigned character to write to the output stream.


writeUInt16(num)

Write an integer to the output stream.

Parameters:
Name Type Description
num number

An integer to write to the output stream.


writeUInt32(num)

Write an integer to the output stream.

Parameters:
Name Type Description
num number

An integer to write to the output stream.


writeUInt64(num)

Write an integer to the output stream.

Parameters:
Name Type Description
num number

An integer to write to the output stream.