public void Print(PrintPageEventArgs e) { string dataPath = _DataPaths[_SignIndex]; _SignIndex++; try { string dataFile = Path.GetFileName(dataPath); string dataFolder = Path.GetDirectoryName(dataPath); MacroValues macros = new MacroValues(); SingleSign.AddStandardMacroValues(macros); AddUserMacros(macros); XmlDocument dataDoc = SingleSign.CreateEmptySignDataDoc(); dataDoc.Load(Path.Combine(dataFolder, dataFile)); SingleSign.AddDataFileMacros(macros, dataFolder, dataDoc); string templateFile = Path.GetFileName(_TemplatePath); string templateFolder = Path.GetDirectoryName(_TemplatePath); SingleSign singleSign = new SingleSign(); singleSign.Print(templateFile, templateFolder, macros, dataFolder, e); } catch (Exception ex) { throw new Exception("Error in sign data file " + dataPath, ex); } e.HasMorePages = (_SignIndex < _SignCount); }
private void docSign_PrintPage(object sender, PrintPageEventArgs e) { try { string dataFolder = _PlantFolder; string templateFile = Path.GetFileName(_TemplatePath); string templateFolder = Path.GetDirectoryName(_TemplatePath); MacroDefinitions macroDefs = new MacroDefinitions(); SingleSign.LoadMacroDefinitions(templateFile, templateFolder, macroDefs); MacroValues macros = new MacroValues(); SingleSign.AddStandardMacroValues(macros); foreach (MacroDefinition macroDef in macroDefs) { macros[macroDef.Name] = macroDef.Value; } XmlDocument dataDoc = SingleSign.CreateEmptySignDataDoc(); dataDoc.LoadXml(txtPlantFileContents.Text); SingleSign.AddDataFileMacros(macros, dataFolder, dataDoc); SingleSign singleSign = new SingleSign(); singleSign.Print(templateFile, templateFolder, macros, dataFolder, e); e.HasMorePages = false; } catch (Exception ex) { SingleSign.ShowException(ex); } }