123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using ComPDFKit.PDFDocument;
- using ComPDFKitViewer.PdfViewer;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace compdfkit_tools.PDFControl
- {
- /// <summary>
- /// PDFSecurityInfoControl.xaml 的交互逻辑
- /// </summary>
- public partial class CPDFSecurityInfoControl : UserControl
- {
- private string T_Allowed = "Allowed";
- private string T_NotAllowed = "Not Allowed";
- public CPDFViewer pdfViewer;
- public void InitWithPDFViewer(CPDFViewer pdfViewer)
- {
- this.pdfViewer = pdfViewer;
- InitializeSecurityInfo(pdfViewer.Document);
- }
- public CPDFSecurityInfoControl()
- {
- InitializeComponent();
- }
- /// <summary>
- /// Pass in a boolean value and return the corresponding text.
- /// </summary>
- /// <param name="isTrue"></param>
- /// <returns></returns>
- private string GetStringFromBool(bool isTrue)
- {
- if (isTrue)
- {
- return T_Allowed;
- }
- else
- {
- return T_NotAllowed;
- }
- }
- private void InitializeSecurityInfo(CPDFDocument pdfDocument)
- {
- CPDFPermissionsInfo Permissions = pdfDocument.GetPermissionsInfo();
- AllowsPrintingTextBlock.Text = GetStringFromBool(Permissions.AllowsPrinting);
- AllowsCopyingTextBlock.Text = GetStringFromBool(Permissions.AllowsCopying);
- AllowsDocumentChangesTextBlock.Text = GetStringFromBool(Permissions.AllowsDocumentChanges);
- AllowsDocumentAssemblyTextBlock.Text = GetStringFromBool(Permissions.AllowsDocumentAssembly);
- AllowsCommentingTextBlock.Text = GetStringFromBool(Permissions.AllowsCommenting);
- AllowsFormFieldEntryTextBlock.Text = GetStringFromBool(Permissions.AllowsFormFieldEntry);
- }
- }
- }
|