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.
MappedFile file = new MappedFile("my_stream.txt");
FilterReader reader = new FilterReader(file);
while (reader.read(...)) ...
Inheritance
Implements
Inherited Members
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 ref byte Begin()
Returns
Type | Description |
---|---|
byte | beginning of the buffer of |
CanSeek()
Check whether the stream supports seeking.
Declaration
public virtual bool CanSeek()
Returns
Type | Description |
---|---|
bool |
|
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
Consume(int)
Moves the Begin() pointer num_bytes forward.
Declaration
public virtual void Consume(int num_bytes)
Parameters
Type | Name | Description |
---|---|---|
int | num_bytes | number of bytes to consume. num_bytes must be less than or equal to |
Count()
Get the number of bytes consumed since opening the filter or the last Seek operation
Declaration
public virtual int Count()
Returns
Type | Description |
---|---|
int | 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(bool)
Declaration
[HandleProcessCorruptedStateExceptions]
protected virtual void Dispose(bool A_0)
Parameters
Type | Name | Description |
---|---|---|
bool | A_0 |
~Filter()
Allows a Filter to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
Declaration
protected ~Filter()
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 |
---|---|
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 |
---|---|
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 |
---|---|
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 |
---|---|
bool |
|
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 |
|
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
Seek(int, 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 |
---|---|---|
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 |
SetCount(int)
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 |
---|---|---|
int | new_count | new counting point |
Returns
Type | Description |
---|---|
int | the value of previous counter |
SetStreamLength(int)
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 |
---|---|---|
int | 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 |
---|---|
int | the size of buffer returned by |
Tell()
Reports the current read position in the stream relative to the stream origin.
Declaration
public virtual int Tell()
Returns
Type | Description |
---|---|
int |
|
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
WriteToFile(string, bool)
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 |
---|---|---|
string | path | The output filepath. |
bool | append | 'Frue' to append to existing file contents, 'False' to overwrite. |