Method LoadDocument
LoadDocument(string, DocumentMetadata, CancellationToken)
Loads a PDF document from the specified file path.
public DocumentIndexingResult LoadDocument(string filePath, DocumentRag.DocumentMetadata documentMetadata = null, CancellationToken cancellationToken = default)
Parameters
filePathstringPath to the PDF file.
documentMetadataDocumentRag.DocumentMetadataOptional metadata to associate with the document. If
null, default metadata is created using the file name. Use this to specify a custom document name, reference URL, or additional metadata fields for source attribution in query results.cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- DocumentIndexingResult
A DocumentIndexingResult describing how the document was processed, including the indexing mode, page count, and token count.
Exceptions
- InvalidOperationException
Thrown if the conversation has already started.
- FileNotFoundException
Thrown if the specified file does not exist.
- ObjectDisposedException
Thrown if this instance has been disposed.
LoadDocument(Stream, string, DocumentMetadata, CancellationToken)
Loads a PDF document from a stream.
public DocumentIndexingResult LoadDocument(Stream stream, string documentName, DocumentRag.DocumentMetadata documentMetadata = null, CancellationToken cancellationToken = default)
Parameters
streamStreamStream containing PDF data.
documentNamestringDisplay name for the document.
documentMetadataDocumentRag.DocumentMetadataOptional metadata to associate with the document. If
null, default metadata is created usingdocumentName. Use this to specify a custom document name, reference URL, or additional metadata fields for source attribution in query results.cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- DocumentIndexingResult
A DocumentIndexingResult describing how the document was processed, including the indexing mode, page count, and token count.
Exceptions
- InvalidOperationException
Thrown if the conversation has already started, or if PageProcessingMode is DocumentUnderstanding and DocumentVisionParser is not set.
- ArgumentNullException
Thrown if
streamordocumentNameisnullor empty.- ObjectDisposedException
Thrown if this instance has been disposed.