示例#1
0
        private void Button1_Click(object sender, System.EventArgs e)
        {
            //The text file "TextFile.txt"
            string fileName = @"TextFile.txt";
            string filePath = Server.MapPath("temp/" + fileName);

            // Create a new PdfWriter
            TextPDF.PdfWriter pdfWriter = new TextPDF.PdfWriter(842.0f, 1190.0f, 10.0f, 10.0f);

            if (filePath.Length > 0)
            {
                //Write to a PDF format file
                pdfWriter.Write(filePath);
            }
        }
        private void bnSaveCAAnalysis_Click(object sender, EventArgs e)
        {
            // Save content into temp.txt file
            var appPath      = Assembly.GetExecutingAssembly().Location;
            var appPathArray = appPath.Split('\\');

            Array.Resize <string>(ref appPathArray, appPathArray.Length - 4);
            var    rScriptPath = string.Join("\\", appPathArray);
            string filePath    = $"{rScriptPath}\\datasets\\temp.txt";

            File.WriteAllText(filePath, tbResults.Text);

            // Create a new PdfWriter
            TextPDF.PdfWriter pdfWriter =
                new TextPDF.PdfWriter(842.0f, 1190.0f, 10.0f, 10.0f);

            if (filePath.Length > 0)
            {
                //Write to a PDF file
                pdfWriter.Write(filePath);
            }

            // copy temp file back to datasets directory
            var fileName = DateTime.Now.ToUniversalTime().Ticks.ToString();

            File.Copy(@"C:\temp\txtPdf.pdf", $"{rScriptPath}\\datasets\\{fileName}.pdf");
            File.Delete(@"C:\temp\txtPdf.pdf");
            var msg = $"Analysis saved in file {rScriptPath}\\datasets\\{fileName}.pdf{Environment.NewLine}";

            msg = msg + $"{Environment.NewLine}";
            msg = msg + $"Please make sure you back up all charts created in folder{Environment.NewLine}";
            msg = msg + $"{rScriptPath}\\plots{Environment.NewLine}";
            msg = msg + $"as they will be removed during the next session of analysis";
            MessageBox.Show(msg,
                            "Correspondence Analysis Results Saved",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
        }