private void DoCmdRemovePasswords() { System.Security.SecureString password = new SecureString(); GenericMessageAction <MsgShowEnterPassword, System.Security.SecureString> message = new GenericMessageAction <MsgShowEnterPassword, System.Security.SecureString>( new MsgShowEnterPassword(this._doc), x => password = x); Messenger.Default.Send(message); if (password != null) { string tempFileName = String.Format(App.Current.FindResource("loc_tempDecrypted").ToString(), System.IO.Path.GetFileNameWithoutExtension(this._doc.FileName)) + System.IO.Path.GetExtension(this._doc.FileName); string tempFile = System.IO.Path.Combine(App.TEMP_DIR, tempFileName); PDFActions pdfActions = new PDFActions(); PDFActions.OperationStates state = pdfActions.Decrypt(this._doc, password, ref tempFile); this.Close(tempFile); } }
private void DoCmdConfirm() { PDFActions pdfActions = new PDFActions(); PDFActions.OperationStates state = pdfActions.TryDecrypt(this._doc, this._password); if (state == PDFActions.OperationStates.WrongPassword) { this.Information = App.Current.FindResource("loc_enterPasswordInformation").ToString(); } else { this.Close(this._password); } }
private void DoCmdInsert() { string tempFile = System.IO.Path.Combine(App.TEMP_DIR, this._doc.FileName); int start = Int32.Parse(this.PageStart) - this._doc.PageLabelStart + 1; PDFActions pdfActions = new PDFActions(); PDFActions.OperationStates state = pdfActions.InsertPages(this._doc, start, this._insertPosition, this._fileToMerge, ref tempFile); if (state == PDFActions.OperationStates.PageRangeOutOfDocument) { this.Information = App.Current.FindResource("loc_msgOutOfDocument").ToString(); } else { this.Close(tempFile); } }
private void DoCmdSetPasswords() { SecureString confirmedOpenPassword = null; SecureString confirmedEditPassword = null; if (this.SetOpenPassword == true) { GenericMessageAction <MsgShowConfirmPassword, bool> message = new GenericMessageAction <MsgShowConfirmPassword, bool>( new MsgShowConfirmPassword(this._openPassword, PasswordTypes.Open), x => confirmedOpenPassword = (x == true) ? this._openPassword : null); Messenger.Default.Send(message); } if (this.SetEditPassword == true) { GenericMessageAction <MsgShowConfirmPassword, bool> message = new GenericMessageAction <MsgShowConfirmPassword, bool>( new MsgShowConfirmPassword(this._editPassword, PasswordTypes.Edit), x => confirmedEditPassword = (x == true) ? this._editPassword : null); Messenger.Default.Send(message); } if ((confirmedOpenPassword != null) || (confirmedEditPassword != null)) { string tempFileName = String.Format(App.Current.FindResource("loc_tempEncrypted").ToString(), System.IO.Path.GetFileNameWithoutExtension(this._doc.FileName)) + System.IO.Path.GetExtension(this._doc.FileName); string tempFile = System.IO.Path.Combine(App.TEMP_DIR, tempFileName); PDFActions pdfActions = new PDFActions(); PDFActions.OperationStates state = pdfActions.Encrypt(this._doc, confirmedOpenPassword, confirmedEditPassword, this.AllowPrinting, this.AllowDegradatedPrinting, this.AllowModifyContents, this.AllowAssembly, this.AllowCopyContents, this.AllowScreenReaders, this.AllowModifyAnnotations, this.AllowFillIn, this.AllowAll, ref tempFile); this.Close(tempFile); } }
private void DoCmdRotate() { string tempFile = System.IO.Path.Combine(App.TEMP_DIR, this._doc.FileName); int start = Int32.Parse(this.PageStart) - this._doc.PageLabelStart + 1; int end = Int32.Parse(this.PageEnd) - this._doc.PageLabelStart + 1; PDFActions pdfActions = new PDFActions(); PDFActions.PageIntervals interval = this.SelectedPageInterval.Id; PDFActions.Rotations rotation = this.SelectedRotation.Id; PDFActions.OperationStates state = pdfActions.RotatePages(this._doc, start, end, interval, rotation, ref tempFile); if (state == PDFActions.OperationStates.PageRangeOutOfDocument) { this.Information = App.Current.FindResource("loc_msgOutOfDocument").ToString(); } else { this.Close(tempFile); } }
private void DoCmdExtract() { string tempFileName = String.Format(App.Current.FindResource("loc_tempPagesFrom").ToString(), System.IO.Path.GetFileNameWithoutExtension(this._doc.FileName)) + System.IO.Path.GetExtension(this._doc.FileName); string tempFile = System.IO.Path.Combine(App.TEMP_DIR, tempFileName); int start = Int32.Parse(this.PageStart) - this._doc.PageLabelStart + 1; int end = Int32.Parse(this.PageEnd) - this._doc.PageLabelStart + 1; PDFActions pdfActions = new PDFActions(); PDFActions.OperationStates state = pdfActions.ExtractPages(this._doc, start, end, ref tempFile); if (state == PDFActions.OperationStates.PageRangeOutOfDocument) { this.Information = App.Current.FindResource("loc_msgOutOfDocument").ToString(); } else { this.Close(tempFile); } }