private void Merge(pdfforge.PDF.PDF pdf) { foreach (object item in PathsListBox.Items) { filePathsList.Add(PathsListBox.GetItemText(item)); } if (filePathsList.Count == 0) { MessageBox.Show("No files added for merging!"); } else { bool exist = System.IO.File.Exists(destinationFilePath); if ((exist == true) /*&& (overwriteSwitch == false)*/) { MessageBox.Show("File already exists, please enter new file name"); } else { files = filePathsList.ToArray(); pdf.MergePDFFiles(ref files, destinationFilePath, false); System.Diagnostics.Process.Start(destinationFilePath); Forget(false); } } }
private void GoButton_Click(object sender, EventArgs e) { pdfforge.PDF.PDF pdf = new pdfforge.PDF.PDF(); if (actionSelected == (int)features.Merge) { Merge(pdf); } else if (actionSelected == (int)features.Explode) { Explode(pdf); } else if (actionSelected == (int)features.StampImage) { Stamp(pdf); } pdf = null; }
private void Explode(pdfforge.PDF.PDF pdf) { foreach (object item in PathsListBox.Items) { filePathsList.Add(PathsListBox.GetItemText(item)); } if (filePathsList.Count == 0) { MessageBox.Show("No files added for exploding!"); } else { foreach (string sourcePath in filePathsList) { pdf.SplitPDFFile(sourcePath, sourcePath); } Forget(true); } }
private void Stamp(pdfforge.PDF.PDF pdf) { foreach (object item in PathsListBox.Items) { filePathsList.Add(PathsListBox.GetItemText(item)); } if (filePathsList.Count == 0) { MessageBox.Show("No PDFs added for stamping!"); } else if (StampFileBox.Items.Count == 0) { MessageBox.Show("No image added for stamping!"); } else { foreach (string sourceFile in filePathsList) { string fileName = System.IO.Path.GetFileNameWithoutExtension(sourceFile); string filePath = System.IO.Path.GetDirectoryName(sourceFile); string destinationFile = filePath + @"\" + fileName + "_1.pdf"; bool exist = System.IO.File.Exists(destinationFile); while (exist == true) { fileName = System.IO.Path.GetFileNameWithoutExtension(destinationFile); destinationFile = filePath + @"\" + fileName + "_1.pdf"; exist = System.IO.File.Exists(destinationFile); } int numberOfPages = pdf.NumberOfPages(sourceFile); string stamp = StampFileBox.GetItemText(StampFileBox.Items[0]); string extension = System.IO.Path.GetExtension(stamp).ToLower(); if (extension == ".pdf") { if (StampAllButton.Checked == true) { pdf.StampPDFFileWithPDFFile(sourceFile, destinationFile, stamp, 1, numberOfPages, true, 0.8f, 9); } else if (StampLastPageButton.Checked == true) { pdf.StampPDFFileWithPDFFile(sourceFile, destinationFile, stamp, numberOfPages, numberOfPages, true, 0.9f, 9); } } else { if (StampAllButton.Checked == true) { pdf.StampPDFFileWithImage(sourceFile, destinationFile, stamp, 1, numberOfPages, true, 0.8f, 9); } else if (StampLastPageButton.Checked == true) { pdf.StampPDFFileWithImage(sourceFile, destinationFile, stamp, numberOfPages, numberOfPages, true, 0.8f, 9); } } } Forget(true); } }