public static void Request1() { var dataSources = new Dictionary<string, DataSource>() { {"", new AdoDataSource("System.Data.SqlClient", "Data Source=mssql.windward.net;Initial Catalog=AdventureWorks;User=demo;Password=demo")} }; var templateFilePath = SampleTemplatesFolder + @"\DataSet.docx"; var outputFilePath = string.Format(@"{0}\DataSetOutput{1}.pdf", SampleTemplatesFolder, rnd.Next()); var datasetFilePath = SampleTemplatesFolder + @"\DataSet.rdlx"; using (var templateFile = File.OpenRead(templateFilePath)) { using (var outputFile = File.Create(outputFilePath)) { using (var datasetFile = File.OpenRead(datasetFilePath)) { var report = new ReportPdf(uri, templateFile, outputFile); report.Datasets = new Dataset[] { new Dataset(datasetFile) }; report.Process(dataSources); } } } }
static void Main(string[] args) { // Initialize the engine Report.Init(); // Open template file and create output file FileStream template = File.OpenRead("../../../../../Data/Samples/Source/WW-Common List.docx"); FileStream output = File.Create("../../../../../Data/Samples/Destination/Xml Common List.docx"); // Create report process Report myReport = new ReportPdf(template, output); // Open an inputfilestream for our data file FileStream Xml = File.OpenRead("../../../../../Data/Data Source/WW-Customers.xml"); // Open a data object to connect to our xml file IReportDataSource data = new XmlDataSourceImpl(Xml, false); // Run the report process myReport.ProcessSetup(); // The second parameter is "" to tell the process that our data is the default data source myReport.ProcessData(data, "Customers"); myReport.ProcessComplete(); // Close out of our template file and output output.Close(); template.Close(); Xml.Close(); // Opens the finished report string fullPath = Path.GetFullPath("../../../../../Data/Samples/Destination/Xml Common List.docx"); System.Diagnostics.Process.Start(fullPath); }
public void Client_PostTemplateAsync() { var dataSources = new Dictionary<string, DataSource>() { {"MANF_DATA_2009", new XmlDataSource(File.OpenRead(SampleTemplatesFolder + @"\Manufacturing.xml"))} }; var templateFilePath = SampleTemplatesFolder + @"\Manufacturing.docx"; var outputFilePath = SampleTemplatesFolder + @"\AsyncOutput.pdf"; using (var templateFile = File.OpenRead(templateFilePath)) { var report = new ReportPdf(uri, templateFile); report.Process(dataSources); while (report.GetStatus() == Report.Status.Working) Thread.Sleep(100); if (report.GetStatus() == Report.Status.Ready) { File.WriteAllBytes(outputFilePath, report.GetReport()); report.Delete(); } } }
public static void Request3() { using (var template = File.OpenRead(SampleTemplatesFolder + @"\Sample1.docx")) { using (var output = new MemoryStream()) { var report = new ReportPdf(uri, template, output); report.Process(); Assert.IsTrue(output.Length > 8); // Compare the first 8 bytes to the '%PDF-1.5' literal. byte[] buffer = new byte[8]; Array.Copy(output.GetBuffer(), buffer, 8); Assert.IsTrue(Enumerable.SequenceEqual(buffer, new byte[] { 0x25, 0x50, 0x44, 0x46, 0x2d, 0x31, 0x2e, 0x35 })); } } }
private async void HandleGeneratePdfReportCommand(object parameter) { try { var reporter = new ReportPdf(); var msg = await reporter.GeneratePdfReport(); MessageBox.Show(msg); } catch (Exception ex) { MessageBox.Show(ex.Message, "Json report"); } }
public static void Request5() { var dataSources = new Dictionary<string, DataSource>() { {"MSSQL", new AdoDataSource("System.Data.SqlClient", "Data Source=mssql.windward.net;Initial Catalog=Northwind;User=demo;Password=demo")} }; var templateFilePath = SampleTemplatesFolder + @"\MsSqlTemplate.docx"; var outputFilePath = string.Format(@"{0}\AdoDataOutput{1}.pdf", SampleTemplatesFolder, rnd.Next()); using (var templateFile = File.OpenRead(templateFilePath)) { using (var outputFile = File.Create(outputFilePath)) { var report = new ReportPdf(uri, templateFile, outputFile); report.Process(dataSources); } } }
public static void Request4() { var dataSources = new Dictionary<string, DataSource>() { {"MANF_DATA_2009", new XmlDataSource(File.OpenRead(SampleTemplatesFolder + @"\Manufacturing.xml"))} }; var templateFilePath = SampleTemplatesFolder + @"\Manufacturing.docx"; var outputFilePath = string.Format(@"{0}\XmlDataOutput{1}.pdf", SampleTemplatesFolder, rnd.Next()); using (var templateFile = File.OpenRead(templateFilePath)) { using (var outputFile = File.Create(outputFilePath)) { var report = new ReportPdf(uri, templateFile, outputFile); report.Process(dataSources); } } }
public static void Request6() { var ds = new XmlDataSource(File.OpenRead(SampleTemplatesFolder + @"\Manufacturing.xml")); ds.Variables = new List<TemplateVariable>() { new TemplateVariable() { Name = "Var1", Value = "hi there" } }; var dataSources = new Dictionary<string, DataSource>() { {"", ds} }; var templateFilePath = SampleTemplatesFolder + @"\Variables.docx"; var outputFilePath = string.Format(@"{0}\VariablesOutput{1}.pdf", SampleTemplatesFolder, rnd.Next()); using (var templateFile = File.OpenRead(templateFilePath)) { using (var outputFile = File.Create(outputFilePath)) { var report = new ReportPdf(uri, templateFile, outputFile); report.Process(dataSources); } } }
public void Client_PostTemplateWithXmlData() { var dataSources = new Dictionary<string, DataSource>() { {"MANF_DATA_2009", new XmlDataSource(File.OpenRead(SampleTemplatesFolder + @"\Manufacturing.xml"))} }; var templateFilePath = SampleTemplatesFolder + @"\Manufacturing.docx"; var outputFilePath = SampleTemplatesFolder + @"\XmlDataOutput.pdf"; using (var templateFile = File.OpenRead(templateFilePath)) { using (var outputFile = File.Create(outputFilePath)) { var report = new ReportPdf(uri, templateFile, outputFile); report.Process(dataSources); } } }
public void Client_PostTemplateWithAdoData() { var dataSources = new Dictionary<string, DataSource>() { {"MSSQL", new AdoDataSource("System.Data.SqlClient", "Data Source=mssql.windward.net;Initial Catalog=Northwind;User=demo;Password=demo")} }; var templateFilePath = SampleTemplatesFolder + @"\MsSqlTemplate.docx"; var outputFilePath = SampleTemplatesFolder + @"\AdoDataOutput.pdf"; using (var templateFile = File.OpenRead(templateFilePath)) { using (var outputFile = File.Create(outputFilePath)) { var report = new ReportPdf(uri, templateFile, outputFile); report.Process(dataSources); } } }