Class PdfFileSource
Namespace: AdCodicem.Pdf.IO
Assembly: AdCodicem.Pdf.dll
The bytes of a PDF file, addressable at random without being held in memory.
public abstract class PdfFileSource : IDisposable
Inheritance
Implements
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
Everything the reader does goes through windows onto this source. A document is therefore never "loaded": the reader keeps an index of where objects live and reads the few hundred bytes of an object when something asks for it.
Properties
Length
Gets the length of the file in bytes.
public abstract long Length { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
Releases resources held by the source.
protected virtual void Dispose(bool disposing)
Parameters
disposing bool
FromFile(string)
Creates a source that reads from a file on demand.
public static PdfFileSource FromFile(string path)
Parameters
path string
Returns
FromMemory(ReadOnlyMemory<byte>)
Creates a source over bytes already in memory.
public static PdfFileSource FromMemory(ReadOnlyMemory<byte> data)
Parameters
data ReadOnlyMemory<byte>
Returns
FromStream(Stream)
Reads a stream fully into memory and serves it from there.
public static PdfFileSource FromStream(Stream stream)
Parameters
stream Stream
Returns
Remarks
A non-seekable stream cannot be read at random, so it is buffered. Callers that care about memory should hand the reader a file path instead.
Read(long, Span<byte>)
Reads into buffer from offset, returning the count read.
public abstract int Read(long offset, Span<byte> buffer)
Parameters
offset long