Example #1
0
        private void StampAndBindButton_Click(object sender, EventArgs e)
        {
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                string stampname = genrateStampImage();
                string pdfname   = tempDir + RandomString(10) + ".pdf";

                using (var combiner = new Combiner(pdfname))
                {
                    progressBar.Visible = true;
                    this.Enabled        = false;

                    for (int i = 0; i < inputListBox.Items.Count; i++)
                    {
                        combiner.AddFiletoBind((string)inputListBox.Items[i]);
                        progressBar.Value = (int)(((i + 1) / (double)inputListBox.Items.Count) * 90);
                    }

                    this.Enabled        = true;
                    progressBar.Visible = false;
                }

                if (File.Exists(stampname))
                {
                    if (File.Exists(pdfname))
                    {
                        Stamper smp = new Stamper();
                        smp.transprency = transprancy;
                        smp.rotation    = angle;
                        smp.x           = x;
                        smp.y           = y;
                        smp.anchor      = anchor;
                        smp.PdfStamp(saveFileDialog.FileName, stampname, pdfname);
                    }
                    else
                    {
                        MessageBox.Show("Binded file \n Does not exist ! skipping file ... \n no file genrated", "Error");
                    }
                }
                else
                {
                    MessageBox.Show("Error with the stamp file input & genration.", "Error");
                }

                System.Diagnostics.Process.Start(saveFileDialog.FileName);
                File.Delete(stampname);
                File.Delete(pdfname);
            }
        }
Example #2
0
        private void StampButton_Click(object sender, EventArgs e)
        {
            if (config.SelectedIndex >= 0)
            {
                progressBar.Visible = true;
                this.Enabled        = false;

                string stampname = genrateStampImage();

                for (int i = 0; i < inputListBox.Items.Count; i++)
                {
                    if (File.Exists(stampname))
                    {
                        if (File.Exists((string)inputListBox.Items[i]))
                        {
                            string outpath = Path.GetDirectoryName((string)inputListBox.Items[i]) + "\\";
                            outpath += Path.GetFileNameWithoutExtension((string)inputListBox.Items[i]) + "_stamped";
                            outpath += Path.GetExtension((string)inputListBox.Items[i]);


                            if (File.Exists(outpath))
                            {
                                DialogResult dialogResult = MessageBox.Show("File aleard exist.\n" + outpath, "Over write ", MessageBoxButtons.YesNo);
                                if (dialogResult == DialogResult.Yes)
                                {
                                    File.Delete(outpath);
                                    Stamper smp = new Stamper();
                                    smp.transprency = transprancy;
                                    smp.rotation    = angle;
                                    smp.x           = x;
                                    smp.y           = y;
                                    smp.anchor      = anchor;
                                    smp.PdfStamp(outpath, stampname, (string)inputListBox.Items[i]);
                                }
                                else if (dialogResult == DialogResult.No)
                                {
                                    //do something else
                                }
                            }
                            else
                            {
                                Stamper smp = new Stamper();
                                smp.transprency = transprancy;
                                smp.rotation    = angle;
                                smp.x           = x;
                                smp.y           = y;
                                smp.anchor      = anchor;
                                smp.PdfStamp(outpath, stampname, (string)inputListBox.Items[i]);
                            }

                            System.Diagnostics.Process.Start(outpath);
                            progressBar.Value = (int)(((i + 1) / (double)inputListBox.Items.Count) * 100);
                        }
                        else
                        {
                            MessageBox.Show("file :" + (string)inputListBox.Items[i] + " \n Does not exist ! skipping file ...", "Error");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Error with the stamp file input & genration.", "Error");
                    }
                }

                this.Enabled        = true;
                progressBar.Visible = false;
                //File.Delete(stampname);
            }
            else
            {
                MessageBox.Show("Select setting");
            }
        }