private void btnCreateTemplate_Click(object sender, RoutedEventArgs e) { try { StringBuilder Sb = new StringBuilder(); string NewFile = String.Empty; using (SharpStamper Stamper = new SharpStamper(m_File)) { foreach (String field in Stamper.Fields) { Sb.AppendLine(String.Format("{0}=", field)); } if (!Directory.Exists(Config.TemplatesDIR)) Directory.CreateDirectory(Config.TemplatesDIR); NewFile = String.Format("{0}/{1}-{2}.ptmpl",Config.TemplatesDIR, Stamper.FileName, DateTime.Now.Ticks); using (StreamWriter sw = new StreamWriter(NewFile)) { sw.Write(Sb.ToString()); } } MessageBox.Show("Template Created", "Success", MessageBoxButton.OK, MessageBoxImage.Information); Process.Start("notepad.exe", NewFile); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void StampTemplate() { string File = String.Empty; SharpStamper Stamper = null; using (Stamper = new SharpStamper(m_File)) { File = String.Format("{0}_{1}_STAMPED.pdf", Stamper.FileName, DateTime.Now.Ticks); Stamper.Stamp(m_TemplateFile); } using (FileStream Fs = new FileStream(File, FileMode.Create)) { byte[] byteStream = Stamper.Output.ToArray(); Fs.Write(byteStream, 0, byteStream.Length); } Process.Start(File); }
private void RunStamper() { try { SharpStamper SharpStamper = new SharpStamper(m_File); lstResult.ItemsSource = SharpStamper.Fields; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }