Auto saving PDFs in UWP
PdfView
can handle saving changes to a StorageFile
automatically. By default, PdfView
’s AutoSave
property is set to AutoSaveMode.None
and you must manually save changes to the document before loading a new PDF into the view or unloading the PdfView
control.
However, by setting AutoSave
to AutoSaveMode.Incremental
or AutoSaveMode.Rewrite
, the PdfView
will attempt to save the file before unloading the document or the PdfView
control.
// Automatically save changes incrementally. myPdfView.AutoSave = AutoSaveMode.Incremental; // Automatically save changes to a rewritten PDF. myPdfView.AutoSave = AutoSaveMode.Rewrite;
Alternatively, you can also set this property in XAML:
<ui:PdfView AutoSave="Incremental" Name="PdfView"/>
See the opening and saving PDFs guide for an explanation of the differences between incremental saving and rewriting.
Exporting events
If you require notification of saving, you can subscribe to two event handlers on the PdfView
.
OnFileExported
is invoked whenever a file has saved successfully, and OnFileExportFailed
is invoked if an error has occurred.