public PageThumbnailCollection(PdfModel pdfModel) { this.pdfModel = pdfModel; this.renderPagesQueue = new Queue <int>(); this.recyclePagesQueue = new Queue <int>(); this.IsInitialized = false; this.visibleRange = new ItemIndexRange(-1, 0); }
/// <summary> /// Initialize a new PDFModel instance from a PDF file. /// </summary> /// <param name="pdfStorageFile"></param> /// <param name="dataFolder"></param> /// <returns></returns> public static async Task <PdfModel> LoadFromFile(StorageFile pdfStorageFile, StorageFolder dataFolder) { PdfModel pdfModel = new PdfModel(pdfStorageFile); await pdfModel.InitializeComponents(dataFolder); if (pdfModel.msPdf == null || pdfModel.sfPdf == null) { return(null); } return(pdfModel); }
public static async Task<PdfModel> LoadFromFile(StorageFile pdfStorageFile) { PdfModel pdfModel = new PdfModel(pdfStorageFile); // Load the file to Microsoft PDF document model // The Microsoft model is used to render the PDF pages. pdfModel.msPdf = await MSPdfModel.LoadFromFile(pdfStorageFile); // Return null if failed to load the file to Microsoft model if (pdfModel.msPdf == null) return null; // Load the file to Syncfusion PDF document model // The Syncfusion model is used to save ink annotations. if (pdfModel.msPdf.isPasswordProtected) { pdfModel.sfPdf = await SFPdfModel.LoadFromFile(pdfStorageFile, pdfModel.msPdf.Password); } else pdfModel.sfPdf = await SFPdfModel.LoadFromFile(pdfStorageFile); // Return null if failed to load the file to Syncfusion model if (pdfModel.sfPdf == null) return null; return pdfModel; }
private async void LoadFile(StorageFile pdfFile) { this.fileLoadingWatch = new System.Diagnostics.Stopwatch(); this.fileLoadingWatch.Start(); if (this.pageCount > 0 && this.imagePanel.Children.Count >= this.pageCount) { AppEventSource.Log.Warn("ViewerPage: Viewer not initialized correctly."); return; } AppEventSource.Log.Info("ViewerPage: Loading file: " + this.pdfStorageFile.Name); // Update UI and Display loading this.fullScreenCover.Visibility = Visibility.Visible; this.fullScreenMessage.Text = "Loading..."; this.filenameTextBlock.Text = this.pdfStorageFile.Name; // Add file the future access list this.futureAccessToken = StorageApplicationPermissions.FutureAccessList.Add(pdfFile); // Save session state in suspension manager SuspensionManager.sessionState = new SessionState(this.futureAccessToken); // Load Pdf file this.pdfModel = await PdfModel.LoadFromFile(pdfFile); // Notify the user and return to main page if failed to load the file. if (this.pdfModel == null) { // Currently, exceptions and notifications are handled within the // pdfModel /MSPdfModel/SFPdfModel class //App.NotifyUser(typeof(ViewerPage), "Failed to open the file.", true); this.CloseAllViews(); return; } // Check future access list await CheckFutureAccessList(); // Create local data folder, if not exist this.dataFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(this.futureAccessToken, CreationCollisionOption.OpenIfExists); AppEventSource.Log.Info("ViewerPage: Finished loading the file in " + fileLoadingWatch.Elapsed.TotalSeconds.ToString()); // Total number of pages this.pageCount = pdfModel.PageCount(); AppEventSource.Log.Debug("ViewerPage: Total pages: " + this.pageCount.ToString()); // Zoom the first page to fit the viewer window width ResetViewer(); // Load drawing preference await LoadDrawingPreference(); // Initialize thumbnails collection this.pageThumbnails = new PageThumbnailCollection(this.pdfModel.PdfDoc); // Render the first page AddBlankImage(1); await AddPageImage(1, (uint)(this.scrollViewer.ActualWidth)); // Add blank pages for the rest of the file using the initialization timer this.initializationTimer.Start(); }
public static async Task <InkingManager> InitializeInking(StorageFolder dataFolder, PdfModel pdfModel) { InkingManager inkManager = new InkingManager(dataFolder); inkManager.inAppInking = await InkingInApp.InitializeInking(dataFolder); inkManager.pdfModel = pdfModel; return(inkManager); }