public static void Run() { // ExStart:SingleRow // The path to the documents directory. string dataDir = RunExamples.GetDataDir_LINQ(); string fileName = "SingleRow.doc"; // Load the template document. Document doc = new Document(dataDir + fileName); // Load the photo and read all bytes. byte[] imgdata = System.IO.File.ReadAllBytes(dataDir + "photo.png"); // Create a Reporting Engine. ReportingEngine engine = new ReportingEngine(); // Execute the build report. engine.BuildReport(doc, Common.GetManager(), "manager"); dataDir = dataDir + RunExamples.GetOutputFilePath(fileName); // Save the finished document to disk. doc.Save(dataDir); // ExEnd:SingleRow Console.WriteLine("\nSingle row template document is populated with the data about manager.\nFile saved at " + dataDir); }
public static void Run() { // ExStart:HelloWorld // The path to the documents directory. string dataDir = RunExamples.GetDataDir_LINQ(); string fileName = "HelloWorld.doc"; // Load the template document. Document doc = new Document(dataDir + fileName); // Create an instance of sender class to set it's properties. Sender sender = new Sender { Name = "LINQ Reporting Engine", Message = "Hello World" }; // Create a Reporting Engine. ReportingEngine engine = new ReportingEngine(); // Execute the build report. engine.BuildReport(doc, sender, "sender"); dataDir = dataDir + RunExamples.GetOutputFilePath(fileName); // Save the finished document to disk. doc.Save(dataDir); // ExEnd:HelloWorld Console.WriteLine("\nTemplate document is populated with the data about the sender.\nFile saved at " + dataDir); }
public static void Run() { // ExStart:BubbleChart // The path to the documents directory. string dataDir = RunExamples.GetDataDir_LINQ(); string fileName = "BubbleChart.docx"; // Load the template document. Document doc = new Document(dataDir + fileName); // Create a Reporting Engine. ReportingEngine engine = new ReportingEngine(); // Execute the build report. engine.BuildReport(doc, Common.GetContracts(), "contracts"); dataDir = dataDir + RunExamples.GetOutputFilePath(fileName); // Save the finished document to disk. doc.Save(dataDir); // ExEnd:BubbleChart Console.WriteLine("\nBubble chart template document is populated with the data about contracts.\nFile saved at " + dataDir); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_LINQ(); string fileName = "InTableAlternateContent.doc"; // Load the template document. Document doc = new Document(dataDir + fileName); // Create a Reporting Engine. ReportingEngine engine = new ReportingEngine(); // Execute the build report. engine.BuildReport(doc, Common.GetContracts(), "contracts"); dataDir = dataDir + RunExamples.GetOutputFilePath(fileName); // Save the finished document to disk. doc.Save(dataDir); Console.WriteLine("\nIn-Table list with alternate content template document is populated with the data about clients and contract price.\nFile saved at " + dataDir); }
public static void Run() { //ExStart:InTableMasterDetail // The path to the documents directory. string dataDir = RunExamples.GetDataDir_LINQ(); string fileName = "InTableMasterDetail.doc"; // Load the template document. Document doc = new Document(dataDir + fileName); // Create a Reporting Engine. ReportingEngine engine = new ReportingEngine(); // Execute the build report. engine.BuildReport(doc, Common.GetManagers(), "managers"); dataDir = dataDir + RunExamples.GetOutputFilePath(fileName); // Save the finished document to disk. doc.Save(dataDir); //ExEnd:InTableMasterDetail Console.WriteLine("\nIn-Table master detail template document is populated with the data about managers and it's contracts.\nFile saved at " + dataDir); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_LINQ(); string fileName = "CommonList.doc"; // Load the template document. Document doc = new Document(dataDir + fileName); // Create a Reporting Engine. ReportingEngine engine = new ReportingEngine(); // Execute the build report. engine.BuildReport(doc, Common.GetManagers(), "managers"); dataDir = dataDir + RunExamples.GetOutputFilePath(fileName); // Save the finished document to disk. doc.Save(dataDir); Console.WriteLine("\nCommon list template document is populated with the data about managers.\nFile saved at " + dataDir); }
static void Main(string[] args) { var type = Type.GetType("MyType"); var type2 = Type.GetType("ConsoleApplication1.MyType"); var type3 = Type.GetType("ConsoleApplication1.MyType, ConsoleApplication1"); var typeName = typeof(MyType).AssemblyQualifiedName; int loopI = 0; for (loopI = 0; loopI < 20; loopI++) { if (loopI == 10) { goto OutsideCondition; } } OutsideCondition: { List <int> myValues = new List <int>(new int[] { 5, 9, 3, 4, 7, 12, 0, 15 }); List <int> newOnly = new List <int>(new int[] { 5, 7, 1, 11, 7, 19, 76, 18 }); List <int> newValues = new List <int>(); for (int i = 0; i < myValues.Count; i++) { for (int x = 0; x < newOnly.Count; x++) { if (!myValues.Contains(newOnly[x])) { newValues.Add(newOnly[x]); } } } } UseSQLCE(); return; #region hide TestDataTableAccess(); GoString(); //EventLogTraceListener e = new EventLogTraceListener() //DelimitedListTraceListener d= new DelimitedListTraceListener("") ; //d.TraceOutputOptions = TraceOptions.ThreadId //TraceSource ts = new TraceSource() Stopwatch sw2 = Stopwatch.StartNew(); for (int i = 1; i <= upperBound; i++) { int j = i; //Task.Run(() => // { // Thread t = new Thread(() => // { using (var engine = new ReportingEngine()) { string outputFile = string.Format(@"C:\Users\mullman\Desktop\Output\XML2PDF {0:00}.pdf", j); List <string> inputs = new List <string>(); inputs.Add(@"C:\Users\mullman\Documents\Visual Studio 2013\Projects\ConsoleApplication1\XML Page 1.html"); inputs.Add(@"C:\Users\mullman\Documents\Visual Studio 2013\Projects\ConsoleApplication1\XML Page 2.html"); engine.RenderXMLAsPDF(outputFile, inputs.ToArray()); } Console.WriteLine("Completed " + j); Interlocked.Increment(ref completed); if (completed == upperBound) { slim.Set(); } // }); // t.Start(); //}); } slim.Wait(); sw2.Stop(); #endregion }
private static void BuildReport(Document document, object dataSource, string dataSourceName) { ReportingEngine engine = new ReportingEngine(); engine.BuildReport(document, dataSource, dataSourceName); }
public void GeneratePDF(SendLetter sendLetter, Guid LetterTemplate) { MemoryStream stream; if (sendLetter.sendLetterFiles == null || sendLetter.sendLetterFiles.Count == 0) { //Create Template and Print letter to Database TemplateManager templateManager = new TemplateManager(); Template template = templateManager.Read(LetterTemplate); stream = new MemoryStream(template.File.Content); if (template != null) { Document doc = new Document(stream); ReportingEngine engine = new ReportingEngine { Options = ReportBuildOptions.AllowMissingMembers }; PrintableSendLetter printableSendLetter = new PrintableSendLetter { DateTime = sendLetter.LetterDateTime.ToPersianTime().toPersianNumber(), Appendage = (sendLetter.Appendages != null && sendLetter.Appendages.Count > 0) ? "دارد" : "ندارد", Number = sendLetter.RowNumber.toPersianNumber(), Body = HttpUtility.HtmlDecode(sendLetter.Body).toPersianNumber(), SenderName = (sendLetter.SenderEmployee?.Employee != null) ? sendLetter.SenderEmployee?.Employee.FullName() : "", //DepartMentName = (sendLetter.SenderEmployee?.Post != null ? sendLetter.SenderEmployee.Post.Name : "") + " " + (sendLetter.SenderEmployee?.Department != null ? sendLetter.SenderEmployee.Department.Name : "") DepartMentName = sendLetter.SenderEmployee?.Post != null?sendLetter.SenderEmployee.Post.Name:"" }; if (sendLetter.Recievers != null && sendLetter.Recievers.Count > 0 && sendLetter.Recievers.First()?.Person != null) { StringBuilder subtitleStbBuilder = new StringBuilder(); subtitleStbBuilder.Append(sendLetter.Recievers.First().Person.Gender == 0 ? "سرکار خانم " : "جناب آقاي "); subtitleStbBuilder.Append(sendLetter.Recievers.First().Person.FullName()); printableSendLetter.SubTitle = subtitleStbBuilder.ToString(); } if (sendLetter.Recievers != null && sendLetter.Recievers.Count > 0 && sendLetter.Recievers.First().Organization != null) { StringBuilder titleStbBuilder = new StringBuilder(); titleStbBuilder.Append(""); if (sendLetter.Recievers.First().Organization != null) { if (sendLetter.Recievers.First().Post != null) { titleStbBuilder.Append(sendLetter.Recievers.First().Post.Name + " محترم "); titleStbBuilder.Append(sendLetter.Recievers.First().Organization.GetFullOrganizationPath()); } printableSendLetter.Title = titleStbBuilder.ToString(); } } // Execute the build report. engine.BuildReport(doc, printableSendLetter, "s"); //Save letter without Appendage as pdf stream = new MemoryStream(); doc.Save(stream, SaveFormat.Pdf); sendLetter.LetterFileContent = stream.ToArray(); } else { //Should send error to User throw new Exception("قالب انتخاب شده یافت نگردید"); } } else { //Render Letter Content With Files Aspose.Pdf.Document contentPdf = new Aspose.Pdf.Document(); foreach (var file in sendLetter.sendLetterFiles) { if (file.File.ContentType.Contains("image")) { Aspose.Pdf.Page page = contentPdf.Pages.Add(); Bitmap b = new Bitmap(new MemoryStream(file.File.Content)); page.PageInfo.Width = b.Width; page.PageInfo.Height = b.Height; // Set margins so image will fit, etc. page.PageInfo.Margin.Bottom = 0; page.PageInfo.Margin.Top = 0; page.PageInfo.Margin.Left = 0; page.PageInfo.Margin.Right = 0; page.CropBox = new Aspose.Pdf.Rectangle(0, 0, b.Width, b.Height); Aspose.Pdf.Image image1 = new Aspose.Pdf.Image(); // Add the image into paragraphs collection of the section page.Paragraphs.Add(image1); // Set the image file stream image1.ImageStream = new MemoryStream(file.File.Content); } else if (file.File.ContentType.Contains("pdf")) { //Append pdf to appendages Aspose.Pdf.Document thisPDF = new Aspose.Pdf.Document(new MemoryStream(file.File.Content)); contentPdf.Pages.Add(thisPDF.Pages); } else if (file.File.ContentType.Contains("word")) { //Convert to pdf first Document thisDoc = new Document(new MemoryStream(file.File.Content)); MemoryStream temp = new MemoryStream(); thisDoc.Save(temp, SaveFormat.Pdf); //Second append it to appendages Aspose.Pdf.Document thisPDF = new Aspose.Pdf.Document(temp); contentPdf.Pages.Add(thisPDF.Pages); } } stream = new MemoryStream(); contentPdf.Save(stream); sendLetter.LetterFileContent = stream.ToArray(); } //Debug //Aspose.Pdf.Document letterFile = new Aspose.Pdf.Document(stream); //letterFile.Save(Server.MapPath("~/LetterOnly.pdf")); //Save letter with Appendage if (sendLetter.Appendages != null && sendLetter.Appendages.Count > 0) { Aspose.Pdf.Document appendagePdf = new Aspose.Pdf.Document(); foreach (var file in sendLetter.Appendages) { if (file.File.ContentType.Contains("image")) { Page page = appendagePdf.Pages.Add(); Bitmap b = new Bitmap(new MemoryStream(file.File.Content)); page.PageInfo.Width = b.Width; page.PageInfo.Height = b.Height; // Set margins so image will fit, etc. page.PageInfo.Margin.Bottom = 0; page.PageInfo.Margin.Top = 0; page.PageInfo.Margin.Left = 0; page.PageInfo.Margin.Right = 0; page.CropBox = new Aspose.Pdf.Rectangle(0, 0, b.Width, b.Height); Aspose.Pdf.Image image1 = new Aspose.Pdf.Image(); // Add the image into paragraphs collection of the section page.Paragraphs.Add(image1); // Set the image file stream image1.ImageStream = new MemoryStream(file.File.Content); } else if (file.File.ContentType.Contains("pdf")) { //Append pdf to appendages Aspose.Pdf.Document thisPDF = new Aspose.Pdf.Document(new MemoryStream(file.File.Content)); appendagePdf.Pages.Add(thisPDF.Pages); } else if (file.File.ContentType.Contains("word")) { //Convert to pdf first Document thisDoc = new Document(new MemoryStream(file.File.Content)); MemoryStream temp = new MemoryStream(); thisDoc.Save(temp, SaveFormat.Pdf); //Second append it to appendages Aspose.Pdf.Document thisPDF = new Aspose.Pdf.Document(temp); appendagePdf.Pages.Add(thisPDF.Pages); } } //Return PDF from letter Aspose.Pdf.Document letterPdf = new Aspose.Pdf.Document(stream); stream = new MemoryStream(); appendagePdf.Save(stream); sendLetter.AppendageContent = stream.ToArray(); //Debug //appendagePdf.Save(Server.MapPath("~/AppendagesOnly.pdf")); letterPdf.Pages.Add(appendagePdf.Pages); stream = new MemoryStream(); letterPdf.Save(stream); //Debug //letterPdf.Save(Server.MapPath("~/letterWithAppendages.pdf")); sendLetter.LetterFileAppendageContent = stream.ToArray(); } }
public void WithAllowMissingDataFields() { Document doc = new Document(); DocumentHelper.InsertNewRun(doc, "<<if [value == “true”] >>ok<<else>>Cancel<</if>>"); DataSet dataSet = new DataSet(); dataSet.ReadXml(TestDir + "DataSet.xml", XmlReadMode.InferSchema); ReportingEngine engine = new ReportingEngine(); engine.Options = ReportBuildOptions.AllowMissingMembers; engine.BuildReport(doc, dataSet, "Bad"); }
private static void BuildReport(Aspose.Words.Document document, object[] dataSource, string[] dataSourceName) { ReportingEngine engine = new ReportingEngine(); engine.BuildReport(document, dataSource, dataSourceName); }