private void createBtn_Click(object sender, RoutedEventArgs e) { createBtn.IsEnabled = false; if (saveData()) { try { //updateRunningNumber(); //this.Close(); //return; using (Report.InvoiceGenerator invoicegen = new Report.InvoiceGenerator()) { /*get inv field for test*/ invoicegen.create(this.invoiceID); //get xml byte[] xmlByte = invoicegen.getByteXml(); //get pdf byte[] pdfByte = invoicegen.getBytePdf(); //get xmlString string xmlString = invoicegen.getStringXml(); PDFA3Invoice pdf = new PDFA3Invoice(); string base_folder = System.AppDomain.CurrentDomain.BaseDirectory; string pdfFilePath = base_folder + "in/pdfA3.pdf"; System.IO.File.WriteAllBytes(pdfFilePath, pdfByte); string xmlFilePath = base_folder + "in/ContentInformation.xml"; string xmlFileName = "ETDA-invoice.xml"; //System.IO.File.WriteAllBytes(xmlFileName, xmlByte); System.IO.File.WriteAllText(xmlFilePath, xmlString, System.Text.Encoding.UTF8); string xmlVersion = "1.0"; string documentID = this.invoiceID; string documentOID = ""; Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = this.invoiceID + ".pdf"; dlg.DefaultExt = ".pdf"; dlg.Filter = "Pdf Files|*.pdf"; bool result = dlg.ShowDialog().Value; if (result == true) { string outputPath = dlg.FileName; pdf.CreatePDFA3Invoice(pdfFilePath, xmlFilePath, xmlFileName, xmlVersion, documentID, documentOID, outputPath, "Tax Invoice"); updateRunningNumber(); this.Close(); } else { createBtn.IsEnabled = true; } } } catch (Exception ex) { createBtn.IsEnabled = true; new AlertBox(ex.Message).ShowDialog(); } } }
private void button1_Click(object sender, RoutedEventArgs e) { //using (StreamReader sr = new StreamReader("..\\..\\Resources\\template.xml")) //{ // string line = sr.ReadToEnd(); // line.IndexOf() //} using (Report.InvoiceGenerator invoicegen = new Report.InvoiceGenerator()) { /*get inv field for test*/ invoicegen.create("ETDA000007"); var a = invoicegen.getStringXml(); var b = invoicegen.getBytePdf(); var c = invoicegen.getByteXml(); } }