Show / Hide Table of Contents

Class Filter

Provides a generic view of a sequence of bytes.

A Filter is the abstract base class of all filters. A filter is an abstraction of a sequence of bytes, such as a file, an input/output device, an inter-process communication pipe, or a TCP/IP socket. The Filter class and its derived classes provide a generic view of these different types of input and output, isolating the programmer from the specific details of the operating system and the underlying devices.

Besides providing access to input/output sources Filters can be also to transform the data (e.g. to compress the data stream, to normalize the image data, to encrypt data, etc). Filters can also be attached to each other to form pipelines. For example, a filter used to open an image data file can be attached to a filter that decompresses the data, which is attached to another filter that will normalize the image data.

Depending on the underlying data source or repository, filters might support only some of these capabilities. An application can query a stream for its capabilities by using the IsInputFilter() and CanSeek() properties.

To read or write data to a filter, a user will typically use FilterReader/FilterWriter class. instead of using Filter methods
  
MappedFile file = new MappedFile("my_stream.txt");
FilterReader reader = new FilterReader(file);
while (reader.read(...)) ...
Inheritance
System.Object
Filter
ASCII85Encode
FlateEncode
MappedFile
MemoryFilter
StreamAdapterFilter
Image2RGB
Implements
System.IDisposable
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: pdftron.Filters
Assembly: PDFNet.dll
Syntax
public class Filter : IDisposable

Methods

AttachFilter(Filter)

Attaches a filter to the this filter. If this filter owns another filter it will be deleted. This filter then becomes the owner of the attached filter.

Declaration
public virtual void AttachFilter(Filter attach_filter)
Parameters
Type Name Description
Filter attach_filter

the attach_filter

Exceptions
Type Condition
PDFNetException

PDFNetException the PDFNet exception

Begin()

Get the begin of the buffer

Declaration
public virtual byte Begin()
Returns
Type Description
System.Byte

beginning of the buffer of Size() bytes that can be used to read or write data.

CanSeek()

Check whether the stream supports seeking.

Declaration
public virtual bool CanSeek()
Returns
Type Description
System.Boolean
  • true if the stream supports seeking; otherwise, false. default is to return false.
Exceptions
Type Condition
PDFNetException

PDFNetException the PDFNet exception

Consume(Int32)

Moves the Begin() pointer num_bytes forward.

Declaration
public virtual void Consume(int num_bytes)
Parameters
Type Name Description
System.Int32 num_bytes

number of bytes to consume. num_bytes must be less than or equal to Size().

Count()

Get the number of bytes consumed since opening the filter or the last Seek operation

Declaration
public virtual int Count()
Returns
Type Description
System.Int32

the number of bytes consumed since opening the filter or the last Seek operation

CreateInputIterator()

Create Filter iterator. Filter iterator similar to a regular filter. However, there can be only one owner of the attached filter.

Declaration
public virtual Filter CreateInputIterator()
Returns
Type Description
Filter

the filter

Remarks
  • Derived classes should make sure that there is only one owner of the attached stream. Otherwise the attached stream may be deleted several times.
Exceptions
Type Condition
PDFNetException

PDFNetException the PDFNet exception

Dispose()

Releases all resources used by the Filter

Declaration
public override sealed void Dispose()

Dispose(Boolean)

Declaration
[HandleProcessCorruptedStateExceptions]
protected virtual void Dispose(bool A_0)
Parameters
Type Name Description
System.Boolean A_0

Finalize()

Allows a Filter to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.

Declaration
protected void Finalize()

Flush()

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

Declaration
public virtual 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 virtual void FlushAll()
Exceptions
Type Condition
PDFNetException

PDFNetException the PDFNet exception

GetAttachedFilter()

Get the attached filter.

Declaration
public virtual Filter GetAttachedFilter()
Returns
Type Description
Filter

attached Filter or a NULL filter if no filter is attached.

Exceptions
Type Condition
PDFNetException

PDFNetException the PDFNet exception

GetDecodeName()

Gets the decode name.

Declaration
public virtual string GetDecodeName()
Returns
Type Description
System.String

string representing the name of corresponding decode filter as it should appear in document (e.g. both ASCIIHexDecode and ASCIIHexEncode should return ASCIIHexDecode).

Exceptions
Type Condition
PDFNetException

PDFNetException the PDFNet exception

GetFilePath()

Gets the file path.

Declaration
public virtual string GetFilePath()
Returns
Type Description
System.String

the file path to the underlying file stream. Default implementation returns empty string.

Exceptions
Type Condition
PDFNetException

PDFNetException the PDFNet exception

GetName()

Gets the name.

Declaration
public virtual string GetName()
Returns
Type Description
System.String

descriptive name of the filter.

Exceptions
Type Condition
PDFNetException

PDFNetException the PDFNet exception

GetSourceFilter()

Get the source filter.

Declaration
public virtual Filter GetSourceFilter()
Returns
Type Description
Filter

the first filter in the chain (usually a file filter)

Exceptions
Type Condition
PDFNetException

PDFNetException the PDFNet exception

IsInputFilter()

Checks if is input filter.

Declaration
public virtual bool IsInputFilter()
Returns
Type Description
System.Boolean
  • boolean indicating whether this is an input filter.
Exceptions
Type Condition
PDFNetException

PDFNetException the PDFNet exception

ReleaseAttachedFilter()

Release the ownership of the attached filter. After the attached filter is released this filter points to NULL filter.

Declaration
public virtual Filter ReleaseAttachedFilter()
Returns
Type Description
Filter
  • Previously attached filter.
Exceptions
Type Condition
PDFNetException

PDFNetException the PDFNet exception

Seek(Int32, Filter.ReferencePos)

When overridden in a derived class, sets the position within the current stream.

Declaration
public virtual void Seek(int offset, Filter.ReferencePos origin)
Parameters
Type Name Description
System.Int32 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

SetCount(Int32)

Sets a new counting point for the current filter. All subsequent Consume() operations will increment this counter. Make sure that the output filter is flushed before using SetCount().

Declaration
public virtual int SetCount(int new_count)
Parameters
Type Name Description
System.Int32 new_count

new counting point

Returns
Type Description
System.Int32

the value of previous counter

SetStreamLength(Int32)

The functions specifies the length of the data stream. The default implementation does not do anything. For some derived filters such as file segment filter it may be useful to override this function in order to limit the stream.

Declaration
public virtual void SetStreamLength(int bytes)
Parameters
Type Name Description
System.Int32 bytes

the new stream length

Exceptions
Type Condition
PDFNetException

PDFNetException the PDFNet exception

Size()

Get size of buffer

Declaration
public virtual int Size()
Returns
Type Description
System.Int32

the size of buffer returned by Begin(). If the Size() returns 0 end of data has been reached.

Tell()

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

Declaration
public virtual int Tell()
Returns
Type Description
System.Int32
  • The current position in the stream
Exceptions
Type Condition
PDFNetException

PDFNetException the PDFNet exception

WriteToFile(String, Boolean)

Writes the entire filter, starting at current position, to specified filepath. Should only be called on an input filter.

Declaration
public void WriteToFile(string path, bool append)
Parameters
Type Name Description
System.String path

The output filepath.

System.Boolean append

'Frue' to append to existing file contents, 'False' to overwrite.

Implements

System.IDisposable
Back to top Generated by DocFX