Show / Hide Table of Contents

# Class FilterWriter

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

##### Inheritance

object
FilterWriter

##### Implements

IDisposable

##### Inherited Members

object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()

###### Namespace: pdftron.Filters

###### Assembly: PDFTronDotNet.dll

##### Syntax

    public class FilterWriter : IDisposable

##### Examples

    StdFile outfile=new StdFile("file.dat"), StdFile.e_write_mode);
    FilterWriter fwriter=new FilterWriter(outfile);
    byte[] buf=...
    fwriter.writeBuffer(buf);
    fwriter.flush();

### Constructors

#### FilterWriter()

Instantiates a new filter writer.

##### Declaration

    public FilterWriter()

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### FilterWriter(Filter)

Instantiates a new filter writer.

##### Declaration

    public FilterWriter(Filter output_filter)

##### Parameters

Type | Name | Description
--- | --- | ---
Filter | output_filter | the filter

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

### Methods

#### AttachFilter(Filter)

Attaches a filter to the this FilterWriter.

##### Declaration

    public void AttachFilter(Filter filter)

##### Parameters

Type | Name | Description
--- | --- | ---
Filter | filter | the filter

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Count()

Count.

##### Declaration

    public int Count()

##### Returns

Type | Description
--- | ---
int | the number of bytes consumed since opening the filter or since the last Seek operation.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Destroy()

##### Declaration

    public void Destroy()

#### Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

##### Declaration

    public void Dispose()

#### Dispose(bool)

##### Declaration

    protected virtual void Dispose(bool disposing)

##### Parameters

Type | Name | Description
--- | --- | ---
bool | disposing |

#### ~FilterWriter()

Releases all resources used by the FilterWriter

##### Declaration

    protected ~FilterWriter()

#### Flush()

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

##### Declaration

    public void Flush()

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### FlushAll()

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

##### Declaration

    public void FlushAll()

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetAttachedFilter()

Gets the attached filter.

##### Declaration

    public Filter GetAttachedFilter()

##### Returns

Type | Description
--- | ---
Filter | The attached Filter or a NULL filter if no filter is attached.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Seek(int, ReferencePos)

Sets the position within the current stream.

##### Declaration

    public void Seek(int offset, Filter.ReferencePos origin)

##### Parameters

Type | Name | Description
--- | --- | ---
int | offset | 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.
Filter.ReferencePos | origin | A value of type ReferencePos indicating the reference point used to obtain the new position

##### Remarks

- After each Seek() operation the number of consumed bytes (i.e. Count()) is set to 0.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Tell()

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

##### Declaration

    public int Tell()

##### Returns

Type | Description
--- | ---
int | The current position in the stream

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### WriteBuffer(byte[])

Write buffer.

##### Declaration

    public int WriteBuffer(byte[] buf)

##### Parameters

Type | Name | Description
--- | --- | ---
byte[] | buf | the buf

##### Returns

Type | Description
--- | ---
int | returns the number of bytes actually written to a stream. This number may less than buf_size if the stream is corrupted.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### WriteFilter(FilterReader)

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

##### Declaration

    public void WriteFilter(FilterReader reader)

##### Parameters

Type | Name | Description
--- | --- | ---
FilterReader | reader | A FilterReader attached to an input stream.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### WriteInt(int)

Write a 32 bit integer to the output stream.

##### Declaration

    public void WriteInt(int num)

##### Parameters

Type | Name | Description
--- | --- | ---
int | num | An integer to write to the output stream.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### WriteInt(long)

Write a 64 bit integer to the output stream.

##### Declaration

    public void WriteInt(long num)

##### Parameters

Type | Name | Description
--- | --- | ---
long | num | An integer to write to the output stream.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### WriteLine(string)

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

##### Declaration

    public void WriteLine(string str)

##### Parameters

Type | Name | Description
--- | --- | ---
string | str | the line

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### WriteString(string)

Write a string to the output stream.

##### Declaration

    public void WriteString(string str)

##### Parameters

Type | Name | Description
--- | --- | ---
string | str | A string to write to the output stream.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### WriteUChar(byte)

Write a single character to the output stream.

##### Declaration

    public void WriteUChar(byte ch)

##### Parameters

Type | Name | Description
--- | --- | ---
byte | ch | An unsigned character to write to the output stream.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

### Implements

IDisposable