Ejemplo n.º 1
0
        public void ConvertUrlToPdf()
        {
            _creator.SetPaths(TEST_URL, PDF_OUT);
            _creator.Create();

            Assert.IsTrue(File.Exists(PDF_OUT), "Pdf was not created");
        }
Ejemplo n.º 2
0
        private void btnSalaryCalculator_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new CupOfCoffeeContext())
            {
                try
                {
                    var pdfFile = new PdfFile();
                    pdfFile.filename = "..\\..\\..\\PDFReport\\employee-sallaries.pdf";
                    pdfFile.title    = "Report: Employees sallaries";
                    pdfFile.data     = SalaryCalculator.Calculate(context);

                    PdfCreator.Create(pdfFile);

                    SalaryRecorder.Insert(pdfFile.data, context);

                    //var pathToAcroRd32 = Environment.GetEnvironmentVariable("ProgramFiles") + @"\Adobe\Reader 11.0\Reader\AcroRd32.exe";
                    //var adobeInfo = new ProcessStartInfo(pathToAcroRd32, pdfFile.filename);

                    MessageBox.Show("The report for employees was successfully generated!",
                                    "Generated successfully",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Information);

                    Process.Start(pdfFile.filename);
                }
                catch (Exception)
                {
                    MessageBox.Show("Cannot generate the report for employees!",
                                    "Generation failed",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }
        }
Ejemplo n.º 3
0
        public virtual ActionResult ListPdf(GroupFilter filter)
        {
            filter.ForPrint = true;
            filter.ForPdf   = true;
            var x      = this.Html.Action("List", filter);
            var result = PdfCreator.Create(x.ToString());

            DownloadResult.AddContentDisposition(this.Response, "расписание.pdf");
            return(File(result, "application/pdf"));
        }
Ejemplo n.º 4
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog fileDialog = new Microsoft.Win32.OpenFileDialog();

            fileDialog.DefaultExt      = ".pdf";
            fileDialog.CheckFileExists = false;

            bool?result = fileDialog.ShowDialog();

            if (result == true)
            {
                var exams = await db.GetFinishedExams(category : Category);

                PdfCreator.Create(exams, fileDialog.FileName);
            }
            Category = null;
        }
Ejemplo n.º 5
0
        public void Save()
        {
            Bestelbon.Name             = BestelbonNaam;
            Bestelbon.Leverancier.Name = Leverancier.Name;
            Bestelbon.Bestelbonregels  = Bestelbonregels;
            Bestelbon.Opmerking        = Opmerking;
            Bestelbon.ProjectDirectory = ProjectDirectory;
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter   = "Astratec Bestelbons(*.abb)|*.abb|All files (*.*)|*.*";
            saveFileDialog1.Title    = "Save Bestelbon";
            saveFileDialog1.FileName = Bestelbon.Name;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                FilePath = saveFileDialog1.FileName;

                string FilePathLevvw   = Properties.Settings.Default.Leveringsvw;
                var    serializerlevvw = new XmlSerializer(typeof(String));
                using (var stream = File.OpenRead(FilePathLevvw))
                {
                    var other = (String)(serializerlevvw.Deserialize(stream));
                    Bestelbon.Leveringsvoorwaarden = "";
                    Bestelbon.Leveringsvoorwaarden = other;
                }


                using (var writer = new System.IO.StreamWriter(FilePath))
                {
                    var serializer = new XmlSerializer(typeof(Bestelbon));
                    serializer.Serialize(writer, Bestelbon);
                    writer.Flush();
                }



                if (Directory.Exists(ProjectDirectory))
                {
                    try
                    {
                        using (var writer = new System.IO.StreamWriter(ProjectDirectory + "\\" + BestelbonNaam))
                        {
                            var serializer = new XmlSerializer(typeof(Bestelbon));
                            serializer.Serialize(writer, Bestelbon);
                            writer.Flush();
                        }
                    }
                    catch (Exception e)
                    {
                        var dialogViewModel = IoC.Get <DialogViewModel>();
                        dialogViewModel.Capiton = "File Open";
                        dialogViewModel.Message = e.ToString();
                        var result = _windowManager.ShowDialog(dialogViewModel);
                    }
                }

                try
                {
                    FileStream fs = new FileStream(FilePath + ".pdf", FileMode.Create);
                    PdfCreator.Create(Bestelbon, CurrentUser, fs);
                    fs.Close();
                    FileStream fsProjectDirectory =
                        new FileStream(ProjectDirectory + "\\" + BestelbonNaam + ".pdf", FileMode.Create);
                    PdfCreator.Create(Bestelbon, CurrentUser, fsProjectDirectory);
                    fsProjectDirectory.Close();
                }
                catch (Exception ex)
                {
                    var dialog = IoC.Get <DialogViewModel>();
                    dialog.Capiton = " Creating file and PDF";
                    dialog.Message = ex.ToString();
                    _windowManager.ShowDialog(dialog);
                }
            }

            _eventAggregator.PublishOnUIThread(message: new BestelbonAdded());
        }