Esempio n. 1
0
        private void BtnAddZUGFeRDExample_Click(object sender, RoutedEventArgs e)
        {
            string inputPDF  = string.Format(@"{0}\Templates\Template.Rechnung.v.1.0.pdf", Environment.CurrentDirectory);
            string outputPDF = string.Format(@"{0}\{1}_{2}.pdf",
                                             Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                                             "ZUGFeRD.konforme.Basic.pdf",
                                             DateTime.Now.ToString("yyyyMMddHHmmss"));

            byte[] zugferdData;

            //make a copy from source pdf
            File.Copy(inputPDF, outputPDF, true);

            //create ZUGFeRD and attach it to pdf
            NE4ZUGFeRDConverter ne4zc = new NE4ZUGFeRDConverter();

            if (ne4zc.CreateSampleZugferdXML(out zugferdData) == null)
            {
                Exception ex = ne4zc.AttachZUGFeRD(outputPDF, zugferdData);
                if (ex == null)
                {
                    MessageBox.Show("ZUGFeRD eingebettet!");
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Esempio n. 2
0
        private void BtnShowZUGFeRD_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter           = "PDF Dateien (*.pdf)|*.pdf";
            ofd.InitialDirectory = Environment.SpecialFolder.MyDocuments.ToString();

            if (ofd.ShowDialog() == true)
            {
                string message = string.Empty;

                NE4ZUGFeRDConverter ne4zc = new NE4ZUGFeRDConverter();
                if (File.Exists(ofd.FileName))
                {
                    Exception ex = ne4zc.ShowZUGFeRD(ofd.FileName, out message);
                    if (ex != null)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    MessageBox.Show(message);
                }
                else
                {
                    MessageBox.Show("Keine Datei gefunden!");
                }
            }
        }