Class TokenWriter
Writes any type of IToken to the corresponding PDF document format output.
public class TokenWriter : ITokenWriter
- Inheritance
-
TokenWriter
- Implements
- Inherited Members
Constructors
TokenWriter()
public TokenWriter()
Fields
StreamEnd
Bytes that indicate end start of stream
protected static readonly byte[] StreamEnd
Field Value
- byte[]
StreamStart
Bytes that indicate start of stream
protected static readonly byte[] StreamStart
Field Value
- byte[]
Properties
Instance
Single global instance
public static TokenWriter Instance { get; }
Property Value
Methods
WriteArray(ArrayToken, Stream)
Write an array to the output stream, with whitespace at the end.
protected void WriteArray(ArrayToken array, Stream outputStream)
Parameters
array
ArrayTokenoutputStream
Stream
WriteBoolean(BooleanToken, Stream)
Write a boolean "true" or "false" to the output stream, with whitespace at the end.
protected void WriteBoolean(BooleanToken boolean, Stream outputStream)
Parameters
boolean
BooleanTokenoutputStream
Stream
WriteComment(CommentToken, Stream)
Write a "%comment" in the output stream, with a line break at the end.
protected void WriteComment(CommentToken comment, Stream outputStream)
Parameters
comment
CommentTokenoutputStream
Stream
WriteCrossReferenceTable(IReadOnlyDictionary<IndirectReference, long>, IndirectReference, Stream, IndirectReference?)
public void WriteCrossReferenceTable(IReadOnlyDictionary<IndirectReference, long> objectOffsets, IndirectReference catalogToken, Stream outputStream, IndirectReference? documentInformationReference)
Parameters
objectOffsets
IReadOnlyDictionary<IndirectReference, long>catalogToken
IndirectReferenceoutputStream
StreamdocumentInformationReference
IndirectReference?
WriteDictionary(DictionaryToken, Stream)
Writes dictionary key/value pairs to output stream as Name/Token pairs.
protected void WriteDictionary(DictionaryToken dictionary, Stream outputStream)
Parameters
dictionary
DictionaryTokenoutputStream
Stream
WriteHex(HexToken, Stream)
Write a hex value to the output stream
protected void WriteHex(HexToken hex, Stream stream)
Parameters
WriteIndirectReference(IndirectReferenceToken, Stream)
Write an indirect reference to the stream, with whitespace at the end.
protected virtual void WriteIndirectReference(IndirectReferenceToken reference, Stream outputStream)
Parameters
reference
IndirectReferenceTokenoutputStream
Stream
WriteInt(int, Stream)
Write an integer to the stream
protected virtual void WriteInt(int value, Stream outputStream)
Parameters
WriteLineBreak(Stream)
Write a line break to the output stream
protected virtual void WriteLineBreak(Stream outputStream)
Parameters
outputStream
Stream
WriteLong(long, Stream)
Write a long to the stream
protected virtual void WriteLong(long value, Stream outputStream)
Parameters
WriteName(NameToken, Stream)
Write a name to the stream, with whitespace at the end.
protected virtual void WriteName(NameToken name, Stream outputStream)
Parameters
WriteNumber(NumericToken, Stream)
Write a number to the stream, with whitespace at the end.
protected virtual void WriteNumber(NumericToken number, Stream outputStream)
Parameters
number
NumericTokenoutputStream
Stream
WriteObject(long, int, byte[], Stream)
public void WriteObject(long objectNumber, int generation, byte[] data, Stream outputStream)
Parameters
WriteObject(ObjectToken, Stream)
Write an object to the stream, with a line break at the end. It writes the following contents:
- "[ObjectNumber] [Generation] obj"
- Object data
- "endobj"
protected virtual void WriteObject(ObjectToken objectToken, Stream outputStream)
Parameters
objectToken
ObjectTokenoutputStream
Stream
WriteStream(StreamToken, Stream)
Write a stream token to the output stream, with the following contents:
- Dictionary specifying the length of the stream, any applied compression filters and additional information.
- Stream start indicator
- Bytes in the StreamToken data
- Stream end indicator
protected virtual void WriteStream(StreamToken streamToken, Stream outputStream)
Parameters
streamToken
StreamTokenoutputStream
Stream
WriteString(StringToken, Stream)
Write string to the stream, with whitespace at the end
protected virtual void WriteString(StringToken stringToken, Stream outputStream)
Parameters
stringToken
StringTokenoutputStream
Stream
WriteToken(IToken, Stream)
Writes the given input token to the output stream with the correct PDF format and encoding including whitespace and line breaks as applicable.
public void WriteToken(IToken token, Stream outputStream)
Parameters
token
ITokenThe token to write to the stream.
outputStream
StreamThe stream to write the token to.
WriteWhitespace(Stream)
Write a space to the output stream
protected virtual void WriteWhitespace(Stream outputStream)
Parameters
outputStream
Stream