public static string FormatConfigurationString(ExportSheet sheet, string value, string extension) { string result = value; result = result.Replace(@"$height", sheet.Height.ToString(CultureInfo.InvariantCulture)); result = result.Replace(@"$width", sheet.Width.ToString(CultureInfo.InvariantCulture)); result = result.Replace(@"$fullExportName", sheet.FullExportName); result = result.Replace(@"$fullExportPath", sheet.FullExportPath(extension)); result = result.Replace(@"$exportDir", sheet.ExportDirectory); result = result.Replace(@"$pageSize", sheet.PageSize); result = result.Replace(@"$projectNumber", sheet.ProjectNumber); result = result.Replace(@"$sheetDescription", sheet.SheetDescription); result = result.Replace(@"$sheetNumber", sheet.SheetNumber); result = result.Replace(@"$sheetRevision", sheet.SheetRevision); result = result.Replace(@"$sheetRevisionDate", sheet.SheetRevisionDate); result = result.Replace(@"$sheetRevisionDescription", sheet.SheetRevisionDescription); result = result.Replace(@"$fileExtension", extension); // search for, and replace Custom Paramters string pattern = @"(__)(.*?)(__)"; result = Regex.Replace( result, pattern, m => RoomConverter.RoomConversionCandidate.GetParamValueAsString(sheet.ParamFromString(m.Groups[2].Value))); return(result); }
public static bool PrintToFile( Document doc, ExportSheet vs, PrintManager pm, string ext, string printerName) { if (pm == null || vs == null) { return(false); } if (vs.SCPrintSetting == null) { vs.UpdateSheetInfo(); return(false); } if (!SetPrinterByName(doc, printerName, pm)) { return(false); } using (var t = new Transaction(doc, "Print Pdf")) { if (t.Start() == TransactionStatus.Started) { try { if (!pm.PrintSetup.IsReadOnly) { pm.PrintSetup.CurrentPrintSetting = vs.SCPrintSetting; pm.PrintRange = PrintRange.Current; pm.PrintToFile = true; pm.PrintToFileName = vs.FullExportPath(ext); pm.Apply(); t.Commit(); return(true); } t.Commit(); return(false); } catch (InvalidOperationException ex) { System.Diagnostics.Debug.WriteLine(ex.Message); t.RollBack(); return(false); } } else { t.RollBack(); return(false); } } }