Class Document

This class represents a PDF Document.

Inheritance
System.Object
Document
Namespace: PSPDFKit.Pdf
Assembly: PSPDFKit.dll
Syntax
public sealed class Document

Properties

| Improve this Doc View Source

DocumentSource

Declaration
public DocumentSource DocumentSource { get; }
Property Value
Type Description
DocumentSource

Methods

| Improve this Doc View Source

CreateAnnotationAsync(IAnnotation)

Creates a new IAnnotation and assigns a local ID.

Declaration
public IAsyncOperation<IAnnotation> CreateAnnotationAsync(IAnnotation annotation)
Parameters
Type Name Description
IAnnotation annotation

An annotation to be created on the currently displayed pages.

Returns
Type Description
Windows.Foundation.IAsyncOperation<IAnnotation>

The newly created IAnnotation.

| Improve this Doc View Source

CreateAttachmentAsync(IBuffer, String)

Creates a new attachment and returns it's ID.

Declaration
public IAsyncOperation<string> CreateAttachmentAsync(IBuffer attachment, string contentType)
Parameters
Type Name Description
Windows.Storage.Streams.IBuffer attachment

The buffer containing the attachment binary.

System.String contentType

The content type of the attachment. E.g. "image/png"

Returns
Type Description
Windows.Foundation.IAsyncOperation<System.String>

An id representing the attachment in the document.

| Improve this Doc View Source

CreateBookmarkAsync(Bookmark)

Add Bookmark to the document. Note that Id is ignored and the returned bookmark will have a new Id.

Declaration
public IAsyncOperation<Bookmark> CreateBookmarkAsync(Bookmark bookmark)
Parameters
Type Name Description
Bookmark bookmark

The bookmark to be created.

Returns
Type Description
Windows.Foundation.IAsyncOperation<Bookmark>

The created bookmark.

| Improve this Doc View Source

DeleteAnnotationAsync(String)

Deletes the IAnnotation specified by the ID.

Declaration
public IAsyncAction DeleteAnnotationAsync(string annotationId)
Parameters
Type Name Description
System.String annotationId

An annotation to be deleted.

Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

DeleteBookmarkAsync(String)

Delete the named Bookmark from the document.

Declaration
public IAsyncAction DeleteBookmarkAsync(string bookmark)
Parameters
Type Name Description
System.String bookmark

The bookmark to be deleted.

Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

ExportAsync(StorageFile)

Export the PDF to a Windows.Storage.StorageFile

Declaration
public IAsyncAction ExportAsync(StorageFile file)
Parameters
Type Name Description
Windows.Storage.StorageFile file

The file into which the current state of the PDF will be saved

Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

ExportAsync(StorageFile, DocumentExportOptions)

Declaration
public IAsyncAction ExportAsync(StorageFile file, DocumentExportOptions options)
Parameters
Type Name Description
Windows.Storage.StorageFile file

The file into which the current state of the PDF will be saved

DocumentExportOptions options

Advanced options for saving a processed document.

Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

ExportFlattenedAsync(StorageFile)

Export the PDF with annotations flattened to a Windows.Storage.StorageFile

Declaration
public IAsyncAction ExportFlattenedAsync(StorageFile file)
Parameters
Type Name Description
Windows.Storage.StorageFile file

The file into which the current state of the PDF will be flattened and saved

Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

ExportFlattenedToDataWriterAsync(DataWriter)

Export the PDF with annotations flattened to a Windows.Storage.Streams.DataWriter. Known issue: Caller must reopen document after exporting with this method.

Declaration
public IAsyncAction ExportFlattenedToDataWriterAsync(DataWriter dataWriter)
Parameters
Type Name Description
Windows.Storage.Streams.DataWriter dataWriter

The Windows.Storage.Streams.DataWriter into which the current state of the PDF will be flattened and written.

Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

ExportInstantJsonAsync()

Return a representation of the current document state in Instant Json.

Declaration
public IAsyncOperation<JsonObject> ExportInstantJsonAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<Windows.Data.Json.JsonObject>

A string holding the Instant Json information.

| Improve this Doc View Source

ExportToDataSinkAsync(IDataSink, DocumentExportOptions)

Export the document to the IDataSink.

Declaration
public IAsyncAction ExportToDataSinkAsync(IDataSink dataSink, DocumentExportOptions options)
Parameters
Type Name Description
IDataSink dataSink

The data sink that the PDF will be written to.

DocumentExportOptions options

Advanced options for saving a processed document.

Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

ExportToDataWriterAsync(DataWriter, DocumentExportOptions)

Export the PDF to a Windows.Storage.Streams.DataWriter. Known issue: Caller must reopen document after exporting with this method.

Declaration
public IAsyncAction ExportToDataWriterAsync(DataWriter dataWriter, DocumentExportOptions options)
Parameters
Type Name Description
Windows.Storage.Streams.DataWriter dataWriter

The Windows.Storage.Streams.DataWriter into which the current state of the PDF will be written.

DocumentExportOptions options

Advanced options for saving a processed document.

Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

ExportXfdfToDataSinkAsync(IDataSink)

Export current annotations to XFDF to a IDataSink.

Declaration
public IAsyncAction ExportXfdfToDataSinkAsync(IDataSink dataSink)
Parameters
Type Name Description
IDataSink dataSink
Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

ExportXfdfToDataWriterAsync(DataWriter)

Export current annotations to XFDF to a Windows.Storage.Streams.DataWriter.

Declaration
public IAsyncAction ExportXfdfToDataWriterAsync(DataWriter dataWriter)
Parameters
Type Name Description
Windows.Storage.Streams.DataWriter dataWriter
Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

GetAnnotationAttachmentAsync(String)

Gets the attachment associated with the Id

Declaration
public IAsyncOperation<Attachment> GetAnnotationAttachmentAsync(string id)
Parameters
Type Name Description
System.String id

The id of the annotation attachment.

Returns
Type Description
Windows.Foundation.IAsyncOperation<Attachment>

An Attachment

| Improve this Doc View Source

GetAnnotationsAsync()

Gets IAnnotations for the whole document.

Declaration
public IAsyncOperation<IList<IAnnotation>> GetAnnotationsAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Collections.Generic.IList<IAnnotation>>

The list of IAnnotations for the entire document.

| Improve this Doc View Source

GetAnnotationsAsync(Int32)

Gets IAnnotations for a specific page index.

Declaration
public IAsyncOperation<IList<IAnnotation>> GetAnnotationsAsync(int pageIndex)
Parameters
Type Name Description
System.Int32 pageIndex
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Collections.Generic.IList<IAnnotation>>

The list of IAnnotations on the specified page.

| Improve this Doc View Source

GetBookmarksAsync()

Get the Bookmarks for this document.

Declaration
public IAsyncOperation<IList<Bookmark>> GetBookmarksAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Collections.Generic.IList<Bookmark>>

A collection of Bookmark.

| Improve this Doc View Source

GetMarkupAnnotationTextAsync(IAnnotation)

Extracts the text behind a markup annotation. This can be useful to get the highlighted text. Warning: This is only an approximation. Highlighted text might not always 100% represent the text, as we just look behind the absolute coordinates to see what text is beneath. PDF highlight annotations are not markers in the content itself.

Declaration
public IAsyncOperation<string> GetMarkupAnnotationTextAsync(IAnnotation annotation)
Parameters
Type Name Description
IAnnotation annotation

The text markup annotation from behind which you want to extract the text.

Returns
Type Description
Windows.Foundation.IAsyncOperation<System.String>

The text behind the annotation.

| Improve this Doc View Source

GetPageSizeAsync(Int32)

Gets the PDF dimensions for the specified page

Declaration
public IAsyncOperation<Size> GetPageSizeAsync(int pageIndex)
Parameters
Type Name Description
System.Int32 pageIndex

The index of the page

Returns
Type Description
Windows.Foundation.IAsyncOperation<Windows.Foundation.Size>

The size of the page

| Improve this Doc View Source

GetTotalPageCountAsync()

Gets the currently opened PDF's total page count.

Declaration
public IAsyncOperation<int> GetTotalPageCountAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Int32>

Page count

| Improve this Doc View Source

ImportInstantJsonAsync(JsonObject)

Load a document state from Instant Json. Will throw if the json is malformed or the pdfid does not match the document which is currently open

Declaration
public IAsyncAction ImportInstantJsonAsync(JsonObject json)
Parameters
Type Name Description
Windows.Data.Json.JsonObject json

A string holding the Instant Json.

Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

ImportXfdfAsync(IDataProvider)

Import XFDF information from a string and display in the current document.

Declaration
public IAsyncAction ImportXfdfAsync(IDataProvider xfdf)
Parameters
Type Name Description
IDataProvider xfdf

A IDataProvider holding the xfdf data.

Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

ImportXfdfFileAsync(StorageFile)

Import XFDF information from a file and display in the current document.

Declaration
public IAsyncAction ImportXfdfFileAsync(StorageFile xfdfFile)
Parameters
Type Name Description
Windows.Storage.StorageFile xfdfFile

The xfdf file to read from.

Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

TextForPageIndexAsync(Int32)

Gets the text for the page at the specified index

Declaration
public IAsyncOperation<IList<TextBlock>> TextForPageIndexAsync(int pageIndex)
Parameters
Type Name Description
System.Int32 pageIndex

The page index

Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Collections.Generic.IList<TextBlock>>

A List of TextBlocks.

| Improve this Doc View Source

UpdateAnnotationAsync(IAnnotation)

Updates an existing IAnnotation.

Declaration
public IAsyncOperation<IAnnotation> UpdateAnnotationAsync(IAnnotation annotation)
Parameters
Type Name Description
IAnnotation annotation

An IAnnotation to be updated.

Returns
Type Description
Windows.Foundation.IAsyncOperation<IAnnotation>

The updated IAnnotation.

| Improve this Doc View Source

UpdateBookmarkAsync(Bookmark)

Update Bookmark to the document.

Declaration
public IAsyncOperation<Bookmark> UpdateBookmarkAsync(Bookmark bookmark)
Parameters
Type Name Description
Bookmark bookmark

The bookmark to be updated.

Returns
Type Description
Windows.Foundation.IAsyncOperation<Bookmark>

The updated bookmark.

Events

| Improve this Doc View Source

AnnotationsCreated

Occurs whenever annotations are created (either via the public Document or via the UI).

Declaration
public event TypedEventHandler<Document, IList<IAnnotation>> AnnotationsCreated
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Document, System.Collections.Generic.IList<IAnnotation>>
| Improve this Doc View Source

AnnotationsDeleted

Occurs whenever annotations are deleted (either via the public Document or via the UI).

Declaration
public event TypedEventHandler<Document, IList<IAnnotation>> AnnotationsDeleted
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Document, System.Collections.Generic.IList<IAnnotation>>
| Improve this Doc View Source

AnnotationsUpdated

Occurs whenever annotations are updated (either via the public Document or via the UI).

Declaration
public event TypedEventHandler<Document, IList<IAnnotation>> AnnotationsUpdated
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Document, System.Collections.Generic.IList<IAnnotation>>
| Improve this Doc View Source

BookmarksCreated

Invoked when bookmarks are created.

Declaration
public event TypedEventHandler<Document, IList<Bookmark>> BookmarksCreated
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Document, System.Collections.Generic.IList<Bookmark>>
| Improve this Doc View Source

BookmarksDeleted

Invoked when bookmarks are deleted.

Declaration
public event TypedEventHandler<Document, IList<Bookmark>> BookmarksDeleted
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Document, System.Collections.Generic.IList<Bookmark>>
| Improve this Doc View Source

BookmarksUpdated

Invoked when bookmarks are updated.

Declaration
public event TypedEventHandler<Document, IList<Bookmark>> BookmarksUpdated
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Document, System.Collections.Generic.IList<Bookmark>>