using Stimulsoft.Base; using Stimulsoft.Report; using Stimulsoft.Report.Dictionary; namespace PdfService; public static class Reporter { public static Stream Print(string reportTemplate, object data) { var report = new StiReport(); report.LoadFromString(reportTemplate); report.RegBusinessObject("Data", data); var currentDirectory = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"../../..")); var fileContent = File.ReadAllBytes(Path.Combine(currentDirectory, "Fonts", "IRANSansWeb.ttf")); var resource = new StiResource("IRANSansMonoSpacedNum", "IRANSansMonoSpacedNum", false, StiResourceType.FontTtf, fileContent, false); report.Dictionary.Resources.Add(resource); StiFontCollection.AddResourceFont(resource.Name, resource.Content, "ttf", resource.Alias); report.Render(false); var stream = new MemoryStream(); report.ExportDocument(StiExportFormat.Pdf ,stream); stream.Position = 0; return stream; } }