コード例 #1
0
        private static void OpenPdf(AxFoxitPDFSDK foxit, string DocumentPath)
        {
            if (foxit != null)
            {
                foxit.UnLockActiveX(C.LICENCE_ID, C.UNLOCK_CODE);
                foxit.ShowTitleBar(false);
                foxit.ShowToolBar(false);
                foxit.ShowNavigationPanels(true);
                foxit.SetShowSavePrompt(false, 0);
                foxit.CurrentTool = C.TEXT_TOOL;
            }

            if (foxit != null)
            {
                try
                {
                    if (!foxit.OpenFile(DocumentPath, null))
                    {
                        AppErrorBox.ShowErrorMessage("Can't open pdf file", "Can't open pdf file");
                    }
                    foxit.CurrentTool = C.TEXT_TOOL;
                    foxit.RemoveEvaluationMark();
                }
                catch (Exception ex)
                {
                    Log.This(ex);
                    AppErrorBox.ShowErrorMessage("Unable to Open PDF", ex.ToString());
                }
            }
        }
コード例 #2
0
 public static void OpenDocument(string DocumentPath)
 {
     try
     {
         if (thisWindow == null)
         {
             thisWindow = new ExportedPDF();
         }
         if (File.Exists(DocumentPath))
         {
             AxFoxitPDFSDK foxit         = thisWindow.PdfHost.Child as AxFoxitPDFSDK;
             AxFoxitPDFSDK foxitSplitted = thisWindow.PdfHostSplitted.Child as AxFoxitPDFSDK;
             OpenPdf(foxit, DocumentPath);
             OpenPdf(foxitSplitted, DocumentPath);
             thisWindow.Show();
         }
         else
         {
             AppInfoBox.ShowInfoMessage("PDF File not Found. Please Try after some time.");
         }
     }
     catch (Exception ex)
     {
         Log.This(ex);
     }
 }
コード例 #3
0
 public void AddReviewedUserId()
 {
     try
     {
         AxFoxitPDFSDK foxit = (PdfHost.Child as AxFoxitPDFSDK);
         if (foxit != null)
         {
             var filepath = foxit.FilePath;
             foxit.CloseFile();
             if (File.Exists(T.MasterTanDataFilePath))
             {
                 var TanInfoDto = JsonConvert.DeserializeObject <TanInfoDTO>(File.ReadAllText(T.MasterTanDataFilePath));
                 TanInfoDto.Tan.DocumentReadCompletedTime = DateTime.Now;
                 TanInfoDto.Tan.DocumentReviwedUser       = U.UserId;
                 string masterTanJson = JsonConvert.SerializeObject(TanInfoDto);
                 System.IO.File.WriteAllText(T.MasterTanDataFilePath, masterTanJson);
             }
             if (File.Exists(filepath))
             {
                 File.Delete(filepath);
             }
         }
     }
     catch (Exception ex)
     {
         Log.This(ex);
     }
 }
コード例 #4
0
        public bool?OpenDocument(string PdfPath, bool showControls = true)
        {
            try
            {
                DialogStatus = false;
                if (File.Exists(PdfPath))
                {
                    string DocumentPath = Path.Combine(T.TanFolderpath, "LocalPdfs", Path.GetFileName(PdfPath));
                    if (!Directory.Exists(Path.GetDirectoryName(DocumentPath)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(DocumentPath));
                    }
                    if (!File.Exists(DocumentPath))
                    {
                        File.Copy(PdfPath, DocumentPath);
                    }

                    AxFoxitPDFSDK foxit         = PdfHost.Child as AxFoxitPDFSDK;
                    AxFoxitPDFSDK foxitSplitted = PdfHostSplitted.Child as AxFoxitPDFSDK;
                    OpenPdf(foxit, DocumentPath);
                    OpenPdf(foxitSplitted, DocumentPath);
                    if (showControls)
                    {
                        CompleteBtn.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        CompleteBtn.Visibility = Visibility.Hidden;
                        Show();
                    }
                    if (showControls)
                    {
                        if (File.Exists(T.MasterTanDataFilePath))
                        {
                            var TanInfoDto = JsonConvert.DeserializeObject <TanInfoDTO>(File.ReadAllText(T.MasterTanDataFilePath));
                            TanInfoDto.Tan.DocumentReadStartTime = DateTime.Now;
                            string masterTanJson = JsonConvert.SerializeObject(TanInfoDto);
                            System.IO.File.WriteAllText(T.MasterTanDataFilePath, masterTanJson);
                        }
                        return(ShowDialog());
                    }
                }
                else
                {
                    AppInfoBox.ShowInfoMessage("PDF File not Found. Please Try after some time.");
                }
                return(false);
            }
            catch (Exception ex)
            {
                Log.This(ex);
            }
            return(null);
        }
コード例 #5
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     try
     {
         AxFoxitPDFSDK foxit = (PdfHost.Child as AxFoxitPDFSDK);
         if (foxit != null)
         {
             foxit.CloseFile();
         }
     }
     catch (Exception ex)
     {
         Log.This(ex);
     }
 }
コード例 #6
0
        private void CollectAnnotations()
        {
            PdfAnnotationsVM vm = thisInstance.DataContext as PdfAnnotationsVM;

            vm.Clear();
            AxFoxitPDFSDK Foxit = (PdfHost.Child as AxFoxitPDFSDK);

            (PdfHost.Child as AxFoxitPDFSDK).UnLockActiveX(C.LICENCE_ID, C.UNLOCK_CODE);
            if (!String.IsNullOrEmpty(FilePath) && File.Exists(FilePath) && Foxit != null)
            {
                try
                {
                    if (Foxit.OpenFile(FilePath, null))
                    {
                        vm.FileName = System.IO.Path.GetFileName(FilePath);
                        Foxit.ForceRefresh();
                        for (int page = 0; page < Foxit.PageCount; page++)
                        {
                            PDFPageAnnots annotations = Foxit.GetPageAnnots(page);
                            int           count       = annotations.GetAnnotsCount();
                            for (int index = 0; index < count; index++)
                            {
                                PDFAnnot annot = annotations.GetAnnot(index);
                                vm.Results.Add(new PdfAnnotationResultVM {
                                    Text = annot.GetContents(), PageNum = page + 1, Author = annot.Author, Type = annot.GetSubType()
                                });
                            }
                        }
                        vm.Results.UpdateDisplayOrder();
                        vm.TotalCount = vm.Results.Count.ToString();
                        Foxit.CloseFile();
                    }
                    else
                    {
                        AppErrorBox.ShowErrorMessage("Pdf can't be opened to collect annotations", $"{FilePath} Can't be opened");
                    }
                }
                catch (Exception ex)
                {
                    AppErrorBox.ShowErrorMessage("Can't collect annotations . . ", ex.ToString());
                    Log.This(ex);
                }
            }
            else
            {
                AppInfoBox.ShowInfoMessage("Pdf file not avaialble");
            }
        }
コード例 #7
0
        private void ReactionsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                string DocumentPath;
                if (ReactionsList.SelectedValue != null)
                {
                    DocumentPath = Path.Combine(C.UserManualsPath, (ReactionsList.SelectedValue as UserManualVM).Value);
                    if (File.Exists(DocumentPath))
                    {
                        AxFoxitPDFSDK foxit = UserPdfHost.Child as AxFoxitPDFSDK;
                        if (foxit != null)
                        {
                            foxit.UnLockActiveX(C.LICENCE_ID, C.UNLOCK_CODE);
                            foxit.ShowTitleBar(false);
                            foxit.ShowToolBar(false);
                            foxit.ShowNavigationPanels(true);
                            foxit.SetShowSavePrompt(false, 0);
                        }

                        if (foxit != null)
                        {
                            if (!foxit.OpenFile(DocumentPath, String.Empty))
                            {
                                AppErrorBox.ShowErrorMessage("Can't open pdf file", "Can't open pdf file");
                            }
                        }
                    }
                    else
                    {
                        AppInfoBox.ShowInfoMessage("PDF File not Found. Please Try after some time.");
                    }
                }
            }
            catch (Exception ex)
            {
                Log.This(ex);
            }
        }