示例#1
0
        static void Main(string[] args)
        {
            // Read our DOCX file a bytes array.
            string inpFile = @"..\..\example.docx";

            byte [] rtfBytes = File.ReadAllBytes(inpFile);

            // We'll use the file only for the demonstration.
            string outFile = @"Result.html";

            byte [] htmlBytes = null;

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();

            // Specify some properties for output HTML document.
            r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.HTML_5;
            r.Encoding     = SautinSoft.RtfToHtml.eEncoding.UTF_8;

            // Imagefolder must already exist.
            r.ImageStyle.ImageFolder = System.Environment.CurrentDirectory;

            // Subfolder for images will be created by the component.
            r.ImageStyle.ImageSubFolder = "image.files";

            // A template name for images.
            r.ImageStyle.ImageFileName = "picture";

            // false - store images as files on HDD,
            // true - store images inside HTML document using base64.
            r.ImageStyle.IncludeImageInHtml = false;

            try
            {
                r.OpenDocx(rtfBytes);

                // Here we've got the HTML document as an array of bytes.
                htmlBytes = r.ToHtml();

                // Save our HTML into file and open it for the demonstration purposes.
                File.WriteAllBytes(outFile, htmlBytes);
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile)
                {
                    UseShellExecute = true
                });
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
                Console.WriteLine("Press any key ...");
                Console.ReadKey();
            }
        }
示例#2
0
        /// <summary>
        /// /
        /// </summary>
        /// <param name="res"></param>
        /// <param name="price"></param>
        /// <param name="payment"></param>
        /// <param name="discount"></param>
        /// <param name="balance"></param>
        /// <param name="FinalAmount"></param>
        /// <returns></returns>
        ///
        public TestResultDto PirntSlip(TestResultDto res, Decimal price, decimal payment, decimal discount, decimal balance, decimal FinalAmount)
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments);

            string fileName = "" + path + "\\paymentSlip.docx";

            var doc = DocX.Create(fileName);

            decimal dis = price * discount;

            doc.InsertParagraph(" _________________________________________________________________________");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("        LAB REPORT MANAGEMENT SYSTEM  | FINAL PAYEMENT DETAIL             ");
            doc.InsertParagraph(" _________________________________________________________________________");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("    Visit ID         : " + res.VisitID + "                                ");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("    Test Price       Rs : " + price + "   Payment  Rs : " + payment + "   ");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("    Discount         Rs : " + dis + "                                     ");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph(" _________________________________________________________________________");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("    Final Amount  Rs : " + FinalAmount + "                                ");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("    Balance Rs     Rs : " + balance + "                                   ");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph(" _________________________________________________________________________");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("                                                                          ");

            doc.Save();

            /*Open as html format*/
            SautinSoft.RtfToHtml z = new SautinSoft.RtfToHtml();
            string docxFile        = Path.GetFullPath(fileName);
            string htmlFile        = Path.ChangeExtension(docxFile, ".html");

            z.OpenDocx(docxFile);
            z.ToHtml(htmlFile);
            System.Diagnostics.Process.Start(htmlFile);

            return(null);
        }
示例#3
0
        static void Main(string[] args)
        {
            string inpFile = @"..\..\example.docx";
            string outFile = @"Result.html";

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();

            // Specify some properties for output HTML document.
            r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.HTML_5;
            r.Encoding     = SautinSoft.RtfToHtml.eEncoding.UTF_8;

            // Imagefolder must already exist.
            r.ImageStyle.ImageFolder = System.Environment.CurrentDirectory;

            // Subfolder for images will be created by the component.
            r.ImageStyle.ImageSubFolder = "image.files";

            // A template name for images.
            r.ImageStyle.ImageFileName = "picture";

            // false - store images as files on HDD,
            // true - store images inside HTML document using base64.
            r.ImageStyle.IncludeImageInHtml = false;

            try
            {
                r.OpenDocx(inpFile);
                r.ToHtml(outFile);

                // Open the result for demonstration purposes.
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile)
                {
                    UseShellExecute = true
                });
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
                Console.WriteLine("Press any key ...");
                Console.ReadKey();
            }
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="printreport"></param>
        /// <returns></returns>
        public TestResultDto PrintReport(TestResultDto printreport)
        {
            MapperConfig.ConfigAutoMapper();



            if (printreport != null)
            {
                int patientid = visit.GetVisit(printreport.VisitID).PatientID;
                var patient   = base.context.Patients.AsNoTracking().FirstOrDefault(p => p.PatientId.Equals(patientid));

                String name    = patient.Name;
                int    age     = patient.Age;
                string sex     = patient.Gender;
                string address = patient.Address;
                string number  = patient.ContactNo;

                DateTime arrivedate = visit.GetVisit(printreport.VisitID).ArriveDate;
                DateTime ExpDelDate = visit.GetVisit(printreport.VisitID).ExpectedDeliveryDate;

                int TesTID       = test.GetTest(printreport.VisitID).TemplateID;
                var testTemplate = base.context.TestTemplates.FirstOrDefault(p => p.TestTemplateId.Equals(TesTID));


                string  templatename = testTemplate.TemplateName;
                int     temID        = testTemplate.TestTemplateId;
                decimal price        = testTemplate.Price;


                IList <TestResultDto>            results = resultSet.GetTestResults(printreport.VisitID);
                IList <TestTemplateAttributeDto> Attribs = VisitHelper.GetTestTemplateAttributes(temID);
                string path     = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments);
                string fileName = "" + path + "\\Report.docx";

                var doc = DocX.Create(fileName);

                doc.InsertParagraph(" __________________________________________________________________________________________________                                  ");
                doc.InsertParagraph("");
                doc.InsertParagraph("                      MEDICAL LAB REPORT MANAGEMENT SYSTEM  |  FINAL TEST REPORT ");
                doc.InsertParagraph("");
                doc.InsertParagraph(" __________________________________________________________________________________________________                                  ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("     Patient Name : " + name + "                                    Gender : " + sex + "                                             ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("     Patient Age : " + age + "                                                        Address:" + address + "   Payment : RS: " + price + "");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("     Contact Number : " + number + "                                    Test : " + templatename + "                                  ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("");

                doc.InsertParagraph("     Arrived Date: " + arrivedate + "                      Deliver Date:" + ExpDelDate + "                                           ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph(" __________________________________________________________________________________________________                                  ");

                doc.InsertParagraph("");
                doc.InsertParagraph("     Patients Results ");
                doc.InsertParagraph("");
                doc.InsertParagraph("");

                int seq = 1;
                foreach (var x in results)
                {
                    doc.InsertParagraph("     " + seq + "           Value: " + x.Value + "              Status : " + x.Status + "");
                    doc.InsertParagraph("");
                    seq++;

                    if (seq > Attribs.Count)
                    {
                        break;
                    }
                }

                doc.InsertParagraph("");
                doc.InsertParagraph("");
                doc.InsertParagraph("    Reffer below Information. ");
                doc.InsertParagraph("");
                doc.InsertParagraph("");

                int NextSeq = 1;
                foreach (var x in Attribs)
                {
                    doc.InsertParagraph("     " + NextSeq + " . " + x.Attribute + " --> " + x.PrefferedLimit + "");
                    doc.InsertParagraph("");
                    doc.InsertParagraph("");
                    NextSeq++;
                }

                doc.Save();

                /*Open as html format*/
                SautinSoft.RtfToHtml z = new SautinSoft.RtfToHtml();
                string docxFile        = Path.GetFullPath(fileName);
                string htmlFile        = Path.ChangeExtension(docxFile, ".html");

                z.OpenDocx(docxFile);
                z.ToHtml(htmlFile);
                System.Diagnostics.Process.Start(htmlFile);

                return(null);
            }

            else
            {
                throw new ArgumentNullException("Provided information is not valid.");
            }
        }