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);
            }
        }
Exemplo n.º 2
0
        private void DoCmdBurst()
        {
            PDFActions pdfActions = new PDFActions();

            pdfActions.Burst(this._doc, this.WorkingDirectory, this.Prefix);

            DialogMessage message = new DialogMessage(this,
                                                      App.Current.FindResource("loc_burstCompletedDialogInformation").ToString(),
                                                      x =>
            {
                if (this.ShowFiles)
                {
                    System.Diagnostics.Process p = new System.Diagnostics.Process();

                    p.StartInfo.FileName = this.WorkingDirectory;

                    p.Start();

                    p.Close();
                }

                this.Close(this.WorkingDirectory);
            })
            {
                Button  = System.Windows.MessageBoxButton.OK,
                Icon    = System.Windows.MessageBoxImage.Information,
                Caption = App.NAME
            };

            Messenger.Default.Send(message);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get the informations from the pdf file
        /// </summary>
        /// <param name="pdfFilePath">Path of the pdf file to get information from</param>
        private void LoadInfo(string pdfFilePath)
        {
            PDFFileInfo info = PDFActions.GetPDFFileInfo(pdfFilePath);

            this.NumberOfPages  = info.NumberOfPages;
            this.PageLabelStart = info.PageLabelStart;
            this.PageRanges     = new List <string>();

            this.HasInfo = true;
            if (this.NumberOfPages == 0)
            {
                this.HasInfo = false;
            }
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 9
0
        private void DoCmdMerge()
        {
            bool ok = true;

            foreach (FileToMergeViewModel f in this.Files)
            {
                if (!f.IsValidInterval)
                {
                    ok = false;
                    break;
                }
            }
            if (!ok)
            {
                this.Information = App.Current.FindResource("loc_correctErrors").ToString();
            }
            else
            {
                string tempFileName = String.Format(App.Current.FindResource("loc_tempMerged").ToString(),
                                                    System.IO.Path.GetFileNameWithoutExtension(this.Files[0].FileName)) +
                                      System.IO.Path.GetExtension(this.Files[0].FileName);
                string tempFile = System.IO.Path.Combine(App.TEMP_DIR, tempFileName);

                PDFDocument[] filesToMerge = (from f in this.Files
                                              select f.PdfDocument).ToArray <PDFDocument>();

                this.MergeProgressMax = filesToMerge.Length;
                this.MergeStarted     = true;
                this.MergeProgress    = 1;

                PDFActions pdfActions = new PDFActions();
                pdfActions.MergeChanged   += new PDFActions.MergeChangedEventHandler(pdfActions_MergeChanged);
                pdfActions.MergeCompleted += new PDFActions.MergeChangedEventHandler(pdfActions_MergeCompleted);

                pdfActions.MergeDocuments(filesToMerge, ref tempFile);
            }
        }