예제 #1
0
        private async void PrintWithoutPdfViewButton_Click(object sender, RoutedEventArgs e)
        {
            var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri ("ms-appx:///Assets/pdfs/PSPDFKit.pdf"));

            var documentSource = DocumentSource.CreateFromStorageFile(file);

            var printHelper = await PrintHelper.CreatePrintHelperFromSourceAsync(documentSource, this, "PrintCanvas", "PrintWithoutUI");

            await printHelper.ShowPrintUIAsync();
        }
예제 #2
0
 /// <summary>
 /// Take the file and call the conroller to open the document.
 /// </summary>
 /// <param name="file">File to open.</param>
 internal async void OpenFile(StorageFile file)
 {
     try
     {
         await _controller.ShowDocumentAsync(DocumentSource.CreateFromStorageFile(file));
     }
     catch (Exception e)
     {
         // Show a dialog with the exception message.
         var dialog = new MessageDialog(e.Message);
         await dialog.ShowAsync();
     }
 }
        /// <summary>
        /// Open a PDF with a password without any UI interaction to provide the password.
        /// </summary>
        public async void OpenPdfViaApi()
        {
            PDFView.Controller.OnRequestPassword += Controller_OnRequestPassword;

            var file = await StorageFile.GetFileFromApplicationUriAsync(
                new Uri ("ms-appx:///Assets/pdfs/PSPDFKit_password_pspdfkit.pdf"));

            var documentSource = DocumentSource.CreateFromStorageFile(file);

            // Set the password in the document source.
            documentSource.Password = "******";

            await PDFView.Controller.ShowDocumentAsync(documentSource);
        }
        public async void OpenPdfPicker()
        {
            try {
                PDFView.Controller.OnRequestPassword += Controller_OnRequestPassword;

                var file = await StorageFile.GetFileFromApplicationUriAsync(
                    new Uri ("ms-appx:///Assets/pdfs/PSPDFKit_password_pspdfkit.pdf"));

                await PDFView.Controller.ShowDocumentAsync(DocumentSource.CreateFromStorageFile(file));
            } catch (Exception e) {
                var messageDialog = new MessageDialog(e.Message);
                await messageDialog.ShowAsync();
            } finally {
                PDFView.Controller.OnRequestPassword -= Controller_OnRequestPassword;
            }
        }
예제 #5
0
        /// <summary>
        /// Take the file and call the conroller to open the document.
        /// </summary>
        /// <param name="file">File to open.</param>
        internal async Task OpenFileAsync(StorageFile file)
        {
            _fileToOpen = file;

            if (_pdfViewInitialised)
            {
                try
                {
                    await PDFView.Controller.ShowDocumentAsync(DocumentSource.CreateFromStorageFile(file));
                }
                catch (Exception e)
                {
                    // Show a dialog with the exception message.
                    var dialog = new MessageDialog(e.Message);
                    await dialog.ShowAsync();
                }
            }
        }
예제 #6
0
        private async void PDFView_InitializationCompletedHandlerAsync(PdfView sender, PSPDFKit.Pdf.Document args)
        {
            await PDFView.Controller.ShowDocumentWithViewStateAsync(DocumentSource.CreateFromStorageFile(_fileToOpen), _viewStateCache);

            _pdfViewInitialised = true;
        }