Viscomsoft UWP PDF Viewer SDK

PDFDocument.OpenAsync Method

 

Open document.
 
 C#

public async Task<bool> OpenAsync(StorageFile file)

 


Parameter
file - the StorageFile object

Namespace: Viscomsoft.UWP.PDFViewerSDK;

Return Value
Return true if sucessful

Example

   

[C# Syntax] 
using Viscomsoft.UWP.PDFViewerSDK;
   
    DocumentFactory factory = new DocumentFactory();

    IDocument doc = factory.CreateDocument(file.Name);

    bool opened = await doc.OpenAsync(file);

    if (opened)
    {
      if (doc.RequiresPassword)
      {

       string strPassword = await InputTextDialogAsync("Password");

       bool passwordApplied = await doc.ApplyPasswordAsync(strPassword);
      
       if (!passwordApplied)
       {
         MessageDialog messageDialog = new MessageDialog("Password is incorrect", "Open File");
         await messageDialog.ShowAsync();
         return;
        }

      }

    }

    _pdfDisplayManager = new PDFDisplayManager();

    _pdfDisplayManager.Width = (int)Window.Current.Bounds.Width;

    _pdfDisplayManager.Height = (int)Window.Current.Bounds.Height;

    _pdfDisplayManager.Document = doc;

    _pdfDisplayManager.GotoPage(1);

    uiViewPanel.Child = createScrollViewControl();