Class PdfStreamAvailability
Provides an interface for managing the availability of PDF data streams, enabling incremental loading and access to PDF documents and their components.
public sealed class PdfStreamAvailability : IDisposable
- Inheritance
-
PdfStreamAvailability
- Implements
- Inherited Members
Remarks
This class is designed to facilitate the loading of PDF documents in scenarios where the data is retrieved incrementally, such as from a network stream. It provides methods to check the availability of the document, individual pages, and form data, as well as to determine whether the file is linearized (optimized for fast web viewing). Instances of this class must be disposed of when no longer needed to release unmanaged resources.
Constructors
PdfStreamAvailability(PdfStreamAvailabilityOptions)
Initializes a new instance of the PdfStreamAvailability class, which provides functionality for managing PDF stream availability using custom data access and availability callbacks.
public PdfStreamAvailability(PdfStreamAvailabilityOptions options)
Parameters
options
PdfStreamAvailabilityOptionsA PdfStreamAvailabilityOptions object that specifies the configuration for the PDF stream availability, including user data, data access callbacks, and availability checks.
Remarks
This constructor initializes the PDF stream availability context by pinning the provided user data and delegates to prevent garbage collection during the lifetime of the instance. It also sets up the necessary native interop structures for managing PDF data availability and download hints.
Exceptions
- ArgumentNullException
Thrown if
options
is null or if any of its required properties (UserData, GetBlock, IsDataAvailable, or RequestSegment) are null.- dotPDFiumException
Methods
Dispose()
Releases all resources used by the current instance of the class.
public void Dispose()
Remarks
This method should be called when the instance is no longer needed to free unmanaged resources and release any allocated handles. After calling this method, the instance should not be used.
IsDocAvailable()
Determines whether the document is available for processing.
public bool IsDocAvailable()
Returns
Remarks
This method checks the availability of the document using the underlying PDF data availability mechanism. It is typically used to verify whether the document can be accessed or processed further.
IsFormAvailable()
Determines whether the form data in the PDF document is available for use.
public bool IsFormAvailable()
Returns
Remarks
This method checks the availability of form data in the PDF document. It may be useful in scenarios where form data needs to be processed or accessed.
IsLinearized()
Returns whether the underlying file is linearized (Fast Web View).
public bool IsLinearized()
Returns
IsPageAvailable(int)
Determines whether the specified page is available for viewing or processing.
public bool IsPageAvailable(int pageIndex)
Parameters
pageIndex
intThe zero-based index of the page to check.
Returns
Remarks
This method checks the availability of a page in the document, which may depend on factors such as the document's loading state or the availability of required resources.
TryLoadDocument(string)
Attempts to load the PDF document from this availability context.
public PdfDocument? TryLoadDocument(string password = "")
Parameters
password
stringThe password, or empty string for no password.
Returns
- PdfDocument
A PdfDocument instance if the document is available; otherwise
null
.
Exceptions
- dotPDFiumException
If PDFium returns an invalid handle despite IsDocAvailable returning true.