Пример #1
0
        public static async Task <PdfDocument> Load(
            string path,
            string password,
            PDFiumCoreManager manager,
            CancellationToken cancellationToken = default)
        {
            await PDFiumCoreManager.Initialize();

            int pages  = -1;
            var result = await manager.Dispatcher.QueueWithResult(() =>
            {
                var document = fpdfview.FPDF_LoadDocument(path, password);
                pages        = fpdfview.FPDF_GetPageCount(document);
                return(document);
            }, DispatcherPriority.Normal, cancellationToken);

            if (result == null)
            {
                return(null);
            }

            var pdfDocument = new PdfDocument(manager, result)
            {
                Pages = pages,
            };

            manager.AddDocument(pdfDocument);

            return(pdfDocument);
        }
Пример #2
0
        public static async Task <PdfDocument> Create(PDFiumCoreManager manager)
        {
            var result = await manager.Dispatcher.QueueWithResult(fpdf_edit.FPDF_CreateNewDocument);

            if (result == null)
            {
                return(null);
            }

            return(new PdfDocument(manager, result));
        }
Пример #3
0
 private PdfDocument(PDFiumCoreManager manager, FpdfDocumentT documentInstance)
 {
     _manager          = manager;
     _documentInstance = documentInstance;
 }