Example #1
0
        private void SaveBtnClick(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog
                {
                    Filter   = "PDF Documents|*.pdf",
                    Title    = "Save PDF File",
                    FileName = _pdfFileName + ".pdf"
                };


                // If the file name is not an empty string open it for saving.
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    String arg     = GetConversionArgs();
                    String pdfFile = PostScriptConverter.PostscriptToPdf(_psFile, arg);

                    Stream myStream = saveFileDialog.OpenFile();
                    {
                        StreamWriter sw = new StreamWriter(myStream, Encoding.Default);
                        sw.Write(pdfFile);
                        sw.Close();

                        MessageBox.Show("Done!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        private void IntegrateBtnClick(object sender, EventArgs e)
        {
            if (alphaCardType_cb.Text == "")
            {
                MessageBox.Show("Please chose a \"AlphaCard Type\"!");
                return;
            }

            string javaPath = Path.Combine(javaPath_tb.Text, "bin\\java.exe");

            if (File.Exists(javaPath) == false)
            {
                MessageBox.Show("Incorrect java path!");
                return;
            }

            String aDoc;

            openFileDialog.Title = "Please choose the α-Doc";
            DialogResult objResult = openFileDialog.ShowDialog();

            if (objResult == DialogResult.OK)
            {
                aDoc = openFileDialog.FileName;
            }
            else
            {
                return;
            }

            String arg     = GetConversionArgs();
            String pdfFile = PostScriptConverter.PostscriptToPdf(_psFile, arg);

            String guidTempFile = Path.GetTempPath() + Guid.NewGuid().ToString() + ".pdf";

            StreamWriter wStream = new StreamWriter(guidTempFile, false, Encoding.Default);

            wStream.Write(pdfFile);
            wStream.Close();


            int result = RunJavaWithArgs(javaPath, aDoc, guidTempFile);

            if (result == 0)
            {
                MessageBox.Show("Done!");
            }

            Close();
        }