Exemple #1
0
        /// <summary>Creates the graph page.</summary>
        /// <param name="section">The section to write to.</param>
        /// <param name="graphPage">The graph and table to convert to html.</param>
        /// <param name="workingDirectory">The working directory.</param>
        private void CreateGraphPage(Section section, GraphPage graphPage, string workingDirectory)
        {
            int numGraphsToPrint = graphPage.graphs.FindAll(g => g.IncludeInDocumentation).Count;

            if (numGraphsToPrint > 0)
            {
                int numColumns = 2;
                int numRows    = (numGraphsToPrint + 1) / numColumns;

                // Export graph to bitmap file.
                Bitmap image = new Bitmap(1800, numRows * 600);
                using (Graphics gfx = Graphics.FromImage(image))
                    using (SolidBrush brush = new SolidBrush(System.Drawing.Color.White))
                    {
                        gfx.FillRectangle(brush, 0, 0, image.Width, image.Height);
                    }
                GraphPresenter graphPresenter = new GraphPresenter();
                ExplorerPresenter.ApsimXFile.Links.Resolve(graphPresenter);
                GraphView graphView = new GraphView();
                graphView.BackColor        = System.Drawing.Color.White;
                graphView.FontSize         = 22;
                graphView.MarkerSize       = 8;
                graphView.Width            = image.Width / numColumns;
                graphView.Height           = image.Height / numRows;
                graphView.LeftRightPadding = 0;

                int col = 0;
                int row = 0;
                for (int i = 0; i < graphPage.graphs.Count; i++)
                {
                    if (graphPage.graphs[i].IncludeInDocumentation)
                    {
                        graphPresenter.Attach(graphPage.graphs[i], graphView, ExplorerPresenter);
                        Rectangle r = new Rectangle(col * graphView.Width, row * graphView.Height,
                                                    graphView.Width, graphView.Height);
                        graphView.Export(image, r, false);
                        graphPresenter.Detach();
                        col++;
                        if (col >= numColumns)
                        {
                            col = 0;
                            row++;
                        }
                    }
                }

                string PNGFileName = Path.Combine(workingDirectory,
                                                  graphPage.graphs[0].Parent.Parent.Name +
                                                  graphPage.graphs[0].Parent.Name +
                                                  graphPage.name + ".png");
                image.Save(PNGFileName, System.Drawing.Imaging.ImageFormat.Png);

                MigraDoc.DocumentObjectModel.Shapes.Image sectionImage = section.AddImage(PNGFileName);
                sectionImage.LockAspectRatio = true;
                sectionImage.Width           = "19cm";
            }
        }
Exemple #2
0
 private void addImage()
 {
     MigraDoc.DocumentObjectModel.Shapes.Image image = section.Headers.Primary.AddImage(@"C:\Users\k.algoursh\Pictures\cat.jpg");
     image.Height             = "1.5cm";
     image.LockAspectRatio    = true;
     image.RelativeVertical   = RelativeVertical.Line;
     image.RelativeHorizontal = RelativeHorizontal.Margin;
     image.Top              = ShapePosition.Top;
     image.Left             = ShapePosition.Right;
     image.WrapFormat.Style = WrapStyle.Through;
 }
Exemple #3
0
        /// <summary>
        /// Creates a MigraDoc image component based on properties
        /// </summary>
        private MigraDoc.DocumentObjectModel.Shapes.Image CreateImage()
        {
            MigraDoc.DocumentObjectModel.Shapes.Image image = new MigraDoc.DocumentObjectModel.Shapes.Image();

            image.Name   = this.path;
            image.Height = Unit.FromMillimeter(this.height);
            image.Width  = Unit.FromMillimeter(this.width);
            image.Left   = this.GetPosition();
            image.WrapFormat.DistanceBottom = Unit.FromMillimeter(5);

            return(image);
        }
Exemple #4
0
 private void AddImageFileToDocument(string filePath)
 {
     currentSection = document.AddSection();
     currentSection.PageSetup.PageFormat   = PageFormat.A4;
     currentSection.PageSetup.TopMargin    = MARGIN;
     currentSection.PageSetup.BottomMargin = MARGIN;
     currentSection.PageSetup.LeftMargin   = MARGIN;
     currentSection.PageSetup.RightMargin  = MARGIN;
     currentParagraph = currentSection.AddParagraph();
     currentParagraph.Format.Alignment = ParagraphAlignment.Center;
     MigraDoc.DocumentObjectModel.Shapes.Image image = currentParagraph.AddImage(filePath);
     ChooseDimensions(filePath, image);
 }
Exemple #5
0
        private static MigraDoc.DocumentObjectModel.Shapes.Image BytesToPdfImage(byte[] bytes, out string pathName,
                                                                                 bool autoRemove = true)
        {
            pathName = Utils.RandomFilePath(".png");
            using (var fs = new FileStream(pathName, FileMode.CreateNew))
            {
                fs.Write(bytes, 0, bytes.Count());
            }
            var res = new MigraDoc.DocumentObjectModel.Shapes.Image(pathName);

            if (autoRemove)
            {
                File.Delete(pathName);
            }
            return(res);
        }
Exemple #6
0
        private static void createHeader(Document document)
        {
            //Add Logo
            try
            {
                string path = Path.GetTempFileName();

                path  = path.Substring(0, path.Length - 3);
                path += "png";

                (Properties.Resources.TECLogo).Save(path, ImageFormat.Png);

                MigraDoc.DocumentObjectModel.Shapes.Image image = document.LastSection.AddImage(path);
                image.Height             = "2.5cm";
                image.LockAspectRatio    = true;
                image.RelativeVertical   = RelativeVertical.Line;
                image.RelativeHorizontal = RelativeHorizontal.Margin;
                image.Top              = ShapePosition.Top;
                image.Left             = ShapePosition.Left;
                image.WrapFormat.Style = WrapStyle.Through;
            }
            catch (IOException e)
            {
                logger.Error("Could not load TECLogo. Exception: " + e.Message);
            }


            //Add Address
            try
            {
                string address      = Properties.Resources.TECAddress;
                var    addressFrame = document.LastSection.AddTextFrame();
                addressFrame.Height             = "2.5cm";
                addressFrame.Width              = "4cm";
                addressFrame.Left               = ShapePosition.Right;
                addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;
                addressFrame.Top = ShapePosition.Top;
                addressFrame.RelativeVertical = RelativeVertical.Line;

                Paragraph addressParagraph = addressFrame.AddParagraph();
                addressParagraph.AddText(address);
            }
            catch (IOException e)
            {
                logger.Error("Could not find TECAddress. Exception: " + e.Message);
            }
        }
Exemple #7
0
        private void ChooseDimensions(string filePath, MigraDoc.DocumentObjectModel.Shapes.Image image)
        {
            System.Drawing.Image currentImage = System.Drawing.Image.FromFile(filePath);
            int width  = currentImage.Width;
            int height = currentImage.Height;

            currentImage.Dispose();
            double ratio;

            image.LockAspectRatio = true;

            if (width > height)
            {
                currentSection.PageSetup.Orientation = MigraDoc.DocumentObjectModel.Orientation.Landscape;
                ratio = (double)width / height;

                if (ratio >= A4_RATIO)
                {
                    image.Width = A4_HEIGHT;
                }
                else
                {
                    image.Height = A4_WIDTH;
                }
            }
            else
            {
                currentSection.PageSetup.Orientation = MigraDoc.DocumentObjectModel.Orientation.Portrait;
                ratio = (double)height / width;

                if (ratio >= A4_RATIO)
                {
                    image.Height = A4_HEIGHT;
                }
                else
                {
                    image.Width = A4_WIDTH;
                }
            }
        }
Exemple #8
0
        private static void AddCompetitionAndLogo(Client.DataAccess c, Section sec)
        {
            String    competitionName = "Competition: " + c.SelectedCompetition.Name;
            Paragraph pg = sec.AddParagraph();

            pg.Format.Alignment    = ParagraphAlignment.Left;
            pg.Format.KeepTogether = false;
            pg.Format.KeepWithNext = false;
            pg.Format.AddTabStop(Unit.FromCentimeter(21));

            FormattedText ft = pg.AddFormattedText(competitionName);

            ft.Bold = true;
            ft.Size = Unit.FromPoint(16);
            pg.AddTab();


            MigraDoc.DocumentObjectModel.Shapes.Image logo = pg.AddImage(@"Resources\ANR_LOGO.jpg");
            logo.Height          = Unit.FromCentimeter(1.912);
            logo.Width           = Unit.FromCentimeter(2.873);
            logo.LockAspectRatio = true;
            logo.Left            = Unit.FromCentimeter(24);
            logo.Top             = Unit.FromCentimeter(0);
        }
Exemple #9
0
        private void print_Form(CNTR_CovidForm_Rec submission)
        {
            string   filename = string.Empty;
            Document document = new Document();
            Section  section;

            Paragraph    answer_Paragraph  = new Paragraph();
            Paragraph    question_Pragraph = new Paragraph();
            Paragraph    header_Paragaraph = new Paragraph();
            List <Color> color_List        = new List <Color>()
            {
                Colors.Goldenrod, Colors.Orange, Colors.Yellow, Colors.Green, Colors.Blue, Colors.Indigo, Colors.Violet
            };
            int i = 0;

            section = document.AddSection();
            MigraDoc.DocumentObjectModel.Shapes.Image centre_Logo = section.Headers.Primary.AddImage("E:/ICSFileServer/Themes/Centre_College_Theme/images/stacked_logo_RGB.jpg");
            ICS_Portal_User user = new JICSBaseFacade <ICS_Portal_User>().GetQuery().Where(x => x.ID == submission.UserID).SingleOrDefault();


            Paragraph centre_Header = section.Headers.Primary.AddParagraph();

            centre_Header.AddText("COVID-19 Self Reporting Form");
            centre_Header.Format.Font.Size = 12;
            centre_Header.Format.Alignment = ParagraphAlignment.Left;

            Paragraph centre_Header_Line2 = section.Headers.Primary.AddParagraph();

            if (user != null)
            {
                centre_Header_Line2.AddText(user.LastName + ", " + user.FirstName + " - " + user.HostID.TrimStart('0'));
            }
            else
            {
                centre_Header_Line2.AddText("Error: User Not Found");
            }
            centre_Header_Line2.Format.Font.Size = 12;
            centre_Header_Line2.Format.Alignment = ParagraphAlignment.Left;

            Paragraph centre_Header_Line3 = section.Headers.Primary.AddParagraph();

            centre_Header_Line3.AddText("Completed: " + submission.SubmittedDate.ToString("dddd, dd MMMM yyyy"));
            centre_Header_Line3.Format.Font.Size = 12;
            centre_Header_Line3.Format.Alignment = ParagraphAlignment.Left;


            centre_Logo.Height             = "2.5cm";
            centre_Logo.LockAspectRatio    = true;
            centre_Logo.RelativeVertical   = RelativeVertical.Line;
            centre_Logo.RelativeHorizontal = RelativeHorizontal.Margin;
            centre_Logo.Top              = ShapePosition.Top;
            centre_Logo.Left             = ShapePosition.Right;
            centre_Logo.WrapFormat.Style = WrapStyle.Through;

            Paragraph centre_Footer = section.Footers.Primary.AddParagraph();

            centre_Footer.AddText("Centre College · 600 West Walnut St · Danville, KY · USA");
            centre_Footer.Format.Font.Size = 9;
            centre_Footer.Format.Alignment = ParagraphAlignment.Center;


            header_Paragaraph = section.AddParagraph("COVID-19 Self Reporting Form");
            header_Paragaraph.Format.Alignment        = ParagraphAlignment.Left;
            header_Paragaraph.Format.Font.Name        = "Times New Roman";
            header_Paragaraph.Format.Font.Color       = Colors.Black;
            header_Paragaraph.Format.Borders.Distance = "5pt";
            header_Paragaraph.Format.Borders.Color    = color_List[i % 7];
            header_Paragaraph.Format.Shading.Color    = color_List[i % 7];
            header_Paragaraph.Format.SpaceBefore      = "2cm";
            header_Paragaraph.Format.Font.Size        = 16;

            Dictionary <string, object> questions = new Dictionary <string, object>()
            {
                { "SubmissionID", submission.SubmissionID },
                { "SubmittedDate:", submission.SubmittedDate },
                { "Temperature over 100.4:", submission.Temp },
                { "ShortnessOfBreath:", submission.ShortnessOfBreath },
                { "Chills:", submission.Chills },
                { "MusclePain:", submission.MusclePain },
                { "SoreThroat:", submission.SoreThroat },
                { "SmellOrTaste:", submission.SmellOrTaste },
                { "CentreID:", submission.CentreID }
            };

            foreach (KeyValuePair <string, object> question in questions)
            {
                question_Pragraph = section.AddParagraph(StripHTML(current_Viewable.nullCheck(question.Key).ToString()));
                question_Pragraph.Format.Alignment        = ParagraphAlignment.Left;
                question_Pragraph.Format.Font.Name        = "Times New Roman";
                question_Pragraph.Format.Font.Color       = Colors.Black;
                question_Pragraph.Format.Font.Size        = 12;
                question_Pragraph.Format.Borders.Distance = "5pt";

                answer_Paragraph = section.AddParagraph(StripHTML(current_Viewable.nullCheck(question.Value).ToString()));
                answer_Paragraph.Format.Alignment  = ParagraphAlignment.Justify;
                answer_Paragraph.Format.Font.Name  = "Times New Roman";
                answer_Paragraph.Format.Font.Color = Colors.DarkGray;
                answer_Paragraph.Format.Font.Size  = 12;
                answer_Paragraph.Format.LeftIndent = "2cm";
            }

            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(false);

            pdfRenderer.Document = document;
            pdfRenderer.RenderDocument();
            filename = "default.pdf";
            EventLog.WriteEntry("ICSNET", "FILENAME:" + filename, EventLogEntryType.Information);
            Response.Clear();
            Response.ContentType = "application/pdf";
            MemoryStream stream = new MemoryStream();

            pdfRenderer.PdfDocument.Save(stream, false);
            Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
            Response.AddHeader("content-length", stream.Length.ToString());
            Response.BinaryWrite(stream.ToArray());
            Response.Flush();
            stream.Close();
            Response.End();
        }
    // generate pdf file
    private string GeneratePDFFile(string customerID)
    {
        Document document = new Document();

        document.DefaultPageSetup.TopMargin    = "1cm";
        document.DefaultPageSetup.LeftMargin   = "1cm";
        document.DefaultPageSetup.RightMargin  = "1cm";
        document.DefaultPageSetup.BottomMargin = "1cm";
        Section section = document.AddSection();

        // insert logo
        MigraDoc.DocumentObjectModel.Shapes.Image logo = section.AddImage(@"C:\Sales Call Report\Exco_logo.png");
        //MigraDoc.DocumentObjectModel.Shapes.Image logo = section.AddImage(@"\\10.0.0.6\Shopdata\Development\tiger\Exco_logo.png");

        logo.LockAspectRatio = true;
        logo.ScaleHeight     = 0.5;
        section.AddParagraph().AddLineBreak();
        // add title
        Paragraph paragraph = section.AddParagraph("Sales Call Report");

        paragraph.Format.Font.Color = Colors.Black;
        paragraph.Format.Font.Bold  = true;
        paragraph.Format.Font.Size  = "30";
        paragraph.Format.Alignment  = ParagraphAlignment.Center;
        section.AddParagraph(DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss")).Format.Alignment = ParagraphAlignment.Center;;
        // add customer information
        string   query           = "select bvadr1, bvadr2, bvadr3, bvadr4, bvtelp, bvfax, bvcont, bvemal from cmsdat.cust where bvcust like '" + customerID + "'";
        string   customerAdd1    = string.Empty;
        string   customerAdd2    = string.Empty;
        string   customerAdd3    = string.Empty;
        string   customerAdd4    = string.Empty;
        string   customerTel     = string.Empty;
        string   customerFax     = string.Empty;
        string   customerContact = string.Empty;
        string   customerEmail   = string.Empty;
        ExcoODBC database        = ExcoODBC.Instance;

        database.Open(Database.CMSDAT);
        OdbcDataReader reader = database.RunQuery(query);

        if (reader.Read())
        {
            customerAdd1    = reader["bvadr1"].ToString().Trim();
            customerAdd2    = reader["bvadr2"].ToString().Trim();
            customerAdd3    = reader["bvadr3"].ToString().Trim();
            customerAdd4    = reader["bvadr4"].ToString().Trim();
            customerTel     = reader["bvtelp"].ToString().Trim();
            customerFax     = reader["bvfax"].ToString().Trim();
            customerContact = reader["bvcont"].ToString().Trim();
            customerEmail   = reader["bvemal"].ToString().Trim().Replace("mailto:", "");
        }
        else
        {
            throw new Exception("Getting customer information failed!");
        }
        reader.Close();
        paragraph = section.AddParagraph();
        paragraph.AddText(CustomerList.Text);
        paragraph.AddLineBreak();
        if (customerContact.Length > 0)
        {
            paragraph.AddText("Contact Person: " + customerContact);
            paragraph.AddLineBreak();
        }
        if (customerAdd1.Length > 0)
        {
            paragraph.AddText(customerAdd1);
            paragraph.AddLineBreak();
        }
        if (customerAdd2.Length > 0)
        {
            paragraph.AddText(customerAdd2);
            paragraph.AddLineBreak();
        }
        if (customerAdd3.Length > 0)
        {
            paragraph.AddText(customerAdd3);
            paragraph.AddLineBreak();
        }
        if (customerAdd4.Length > 0)
        {
            paragraph.AddText(customerAdd4);
            paragraph.AddLineBreak();
        }
        if (customerTel.Length > 0)
        {
            paragraph.AddText("Tel: " + customerTel);
            paragraph.AddLineBreak();
        }
        if (customerFax.Length > 0)
        {
            paragraph.AddText("Fax: " + customerFax);
            paragraph.AddLineBreak();
        }
        if (customerEmail.Length > 0)
        {
            paragraph.AddText("Email: " + customerEmail);
            paragraph.AddLineBreak();
        }
        // add sales person information
        query = "select Email, FirstName, LastName from tiger.dbo.[user] where UserName like '" + User.Identity.Name + "'";
        string salesEmail = string.Empty;
        string salesName  = string.Empty;

        database.Open(Database.DECADE_MARKHAM);
        reader = database.RunQuery(query);
        if (reader.Read())
        {
            salesEmail = reader["Email"].ToString().Trim();
            salesName  = reader["FirstName"].ToString().Trim() + " " + reader["LastName"].ToString().Trim();
        }
        else
        {
            throw new Exception("Getting sales information failed!");
        }
        reader.Close();
        // add sales call report information
        section.AddParagraph().AddLineBreak();
        MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();
        table.Format.Alignment    = ParagraphAlignment.Center;
        table.Style               = "Table";
        table.Borders.Width       = 1;
        table.Borders.Color       = Colors.Black;
        table.Borders.Width       = 0.25;
        table.Borders.Left.Width  = 0.5;
        table.Borders.Right.Width = 0.5;
        table.Rows.LeftIndent     = 0;
        MigraDoc.DocumentObjectModel.Tables.Column column = table.AddColumn("3.5cm");
        column.Format.Alignment = ParagraphAlignment.Center;
        column = table.AddColumn("3cm");
        column.Format.Alignment = ParagraphAlignment.Center;
        column = table.AddColumn("3cm");
        column.Format.Alignment = ParagraphAlignment.Center;
        column = table.AddColumn("3cm");
        column.Format.Alignment = ParagraphAlignment.Center;
        column = table.AddColumn("3cm");
        column.Format.Alignment = ParagraphAlignment.Center;
        column = table.AddColumn("3cm");
        column.Format.Alignment = ParagraphAlignment.Center;
        MigraDoc.DocumentObjectModel.Tables.Row row = table.AddRow();
        row.Cells[0].AddParagraph("Sales");
        row.Cells[0].Format.Font.Bold = true;
        row.Cells[1].MergeRight       = 1;
        row.Cells[1].AddParagraph(salesName);
        row.Cells[3].AddParagraph("Email");
        row.Cells[3].Format.Font.Bold = true;
        row.Cells[4].MergeRight       = 1;
        row.Cells[4].AddParagraph(salesEmail);
        row = table.AddRow();
        row.Cells[0].AddParagraph("Visit");
        row.Cells[0].Format.Font.Bold = true;
        row.Cells[1].MergeRight       = 1;
        row.Cells[1].AddParagraph(DateText.Text);
        row.Cells[3].AddParagraph("Follow Up");
        row.Cells[3].Format.Font.Bold = true;
        row.Cells[4].MergeRight       = 1;
        row.Cells[4].AddParagraph(FollowUpText.Text);
        row = table.AddRow();
        row.Cells[0].AddParagraph("Number of Presses");
        row.Cells[0].Format.Font.Bold = true;
        row.Cells[1].AddParagraph(PressText.Text);
        row.Cells[2].AddParagraph("Est. Die Exp./Mn");
        row.Cells[2].Format.Font.Bold = true;
        row.Cells[3].AddParagraph(ExpenseText.Text);
        row.Cells[4].AddParagraph("Other Suppliers");
        row.Cells[4].Format.Font.Bold = true;
        row.Cells[5].AddParagraph(SupplierText.Text);
        row = table.AddRow();
        row.Cells[0].AddParagraph("Attendee's");
        row.Cells[0].Format.Font.Bold = true;
        row.Cells[1].MergeRight       = 4;
        row.Cells[1].AddParagraph(AttendeeText.Text);
        row = table.AddRow();
        row.Cells[0].AddParagraph("Purpose of Visit");
        row.Cells[0].Format.Font.Bold = true;
        row.Cells[1].MergeRight       = 4;
        row.Cells[1].AddParagraph(AdjustWordWrap(PurposeText.Text));
        row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
        row = table.AddRow();
        row.Cells[0].AddParagraph("Addtional Information");
        row.Cells[0].Format.Font.Bold = true;
        row.Cells[1].MergeRight       = 4;
        row.Cells[1].AddParagraph(AdjustWordWrap(InformationText.Text));
        row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
        row = table.AddRow();
        row.Cells[0].AddParagraph("How can ETS Increase Business");
        row.Cells[0].Format.Font.Bold = true;
        row.Cells[1].MergeRight       = 4;
        row.Cells[1].AddParagraph(AdjustWordWrap(IncreaseText.Text));
        row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
        // render pdf
        PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(false, PdfFontEmbedding.Always);

        pdfRenderer.Document = document;
        pdfRenderer.RenderDocument();
        filesubPath = @"sales call report by " + User.Identity.Name + " at " + DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss") + ".pdf";
        //string filePath = @"C:\Sales Call Report\" + filesubPath;
        //string filePath = @"\\10.0.0.6\Shopdata\Development\tiger\Sales Call Report\sales call report by " + User.Identity.Name + " at " + DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss") + ".pdf";
        //string filePath = @"C:\Sales Call Report\" + filesubPath;
        string filePath = Server.MapPath("~/Sales Call Report PDF/" + filesubPath);

        if (Directory.Exists(Server.MapPath("~/Sales Call Report PDF/")))
        {
            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }
        }
        else
        {
            Directory.CreateDirectory(Server.MapPath("~/Sales Call Report PDF/"));
        }

        pdfRenderer.PdfDocument.Save(filePath);

        return(filePath);
    }
Exemple #11
0
        /// <summary>
        /// Render a image into a header or footer
        /// </summary>
        public void RenderInto(HeaderFooter headerFooter)
        {
            MigraDoc.DocumentObjectModel.Shapes.Image image = this.CreateImage();

            headerFooter.Add(image);
        }
Exemple #12
0
        /// <summary>
        /// Render a image into a section
        /// </summary>
        public void RenderInto(MigraDoc.DocumentObjectModel.Section section)
        {
            MigraDoc.DocumentObjectModel.Shapes.Image image = this.CreateImage();

            section.Add(image);
        }
    private void generatePDFFile()
    {
        // Create a MigraDoc document
        Document doc = new Document();

        doc.Info.Title   = "Work Order";
        doc.Info.Subject = "Order No:" + oModOrder.GetSetorderno;
        doc.Info.Author  = "B.I.O.App System";

        //set page orientation
        doc.DefaultPageSetup.Orientation    = MigraDoc.DocumentObjectModel.Orientation.Portrait;
        doc.DefaultPageSetup.TopMargin      = "7.5cm"; //120
        doc.DefaultPageSetup.BottomMargin   = "8.5cm"; //150
        doc.DefaultPageSetup.LeftMargin     = 40;
        doc.DefaultPageSetup.RightMargin    = 40;
        doc.DefaultPageSetup.HeaderDistance = "1.5cm"; //20
        doc.DefaultPageSetup.FooterDistance = "1cm";   //20

        MigraDoc.DocumentObjectModel.Style style = doc.Styles["Normal"];
        // Because all styles are derived from Normal, the next line changes the
        // font of the whole document. Or, more exactly, it changes the font of
        // all styles and paragraphs that do not redefine the font.
        style.Font.Name = "Verdana";

        // Create a new style called Table based on style Normal
        style           = doc.Styles.AddStyle("Table", "Normal");
        style.Font.Name = "Verdana";
        style.Font.Name = "Arial";
        style.Font.Size = 8;

        // Each MigraDoc document needs at least one section.
        Section section = doc.AddSection();

        // Put Capital Digital logo in the header
        string logo_lima = Server.MapPath("~/images/logo_CD_bgBLUE_BLACK_310x98.png");

        MigraDoc.DocumentObjectModel.Shapes.Image image = section.Headers.Primary.AddImage(logo_lima);
        image.Height             = "1cm";
        image.LockAspectRatio    = true;
        image.RelativeVertical   = RelativeVertical.Line;
        image.RelativeHorizontal = RelativeHorizontal.Margin;
        image.Top              = ShapePosition.Top;
        image.Left             = ShapePosition.Right;
        image.WrapFormat.Style = WrapStyle.Through;

        // Put CD logo in the header
        string logo_mod = Server.MapPath("~/images/logo_versi_4.png");

        MigraDoc.DocumentObjectModel.Shapes.Image image2 = section.Headers.Primary.AddImage(logo_mod);
        image2.Height             = "1.5cm";
        image2.LockAspectRatio    = true;
        image2.RelativeVertical   = RelativeVertical.Line;
        image2.RelativeHorizontal = RelativeHorizontal.Margin;
        image2.Top              = ShapePosition.Top;
        image2.Left             = ShapePosition.Left;
        image2.WrapFormat.Style = WrapStyle.Through;

        // Create Header
        Paragraph header = section.Headers.Primary.AddParagraph();

        header.AddText("WORK ORDER FORM");
        header.Format.Font.Size = 12;
        header.Format.Font.Bold = true;
        header.Format.Alignment = ParagraphAlignment.Center;

        // Create main section for Sales Order
        //Paragraph main = section.AddParagraph();
        // main = section.AddParagraph();
        //main.Format.SpaceBefore = 1;

        // Create the item table for header
        //MigraDoc.DocumentObjectModel.Tables.Table tableTop = section.AddTable();
        MigraDoc.DocumentObjectModel.Tables.Table tableTop = section.Headers.Primary.AddTable();
        tableTop.Style               = "Table";
        tableTop.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        tableTop.Borders.Width       = 0.25;
        tableTop.Borders.Left.Width  = 0.5;
        tableTop.Borders.Right.Width = 0.5;
        tableTop.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column columnTop = tableTop.AddColumn("8cm");

        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("3cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("7cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;

        Row rowTop = tableTop.AddRow();

        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible  = false;
        rowTop.Borders.Right.Visible = false;
        rowTop.Borders.Top.Visible   = false;
        //rowTop.Borders.Bottom.Visible = false;
        rowTop.Cells[0].AddParagraph();
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph();
        rowTop.Cells[2].AddParagraph();


        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("From:");
        rowTop.Cells[0].AddParagraph("CAPITAL DIGITAL");
        rowTop.Cells[0].AddParagraph("NO. 1, JALAN BUNGA RAYA 1, LANGKAWI MALL");
        rowTop.Cells[0].AddParagraph("07000 KUAH, LANGKAWI");
        rowTop.Cells[0].AddParagraph("KEDAH DARUL AMAN");
        rowTop.Cells[0].AddParagraph("www.capitaldigital.com.my");
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Top.Visible    = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[0].MergeDown = 5;
        rowTop.Cells[1].AddParagraph("Order No");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetorderno);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Date");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetorderdate);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Type");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetordertype);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Sales Office");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": CAPITAL DIGITAL LANGKAWI");
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Sales Person");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": HAZZARUL ANAS");
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph("Contact No");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": +6017-552 4447");
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("");
        rowTop.Cells[0].MergeRight             = 2;
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Top.Visible    = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[2].Borders.Right.Visible  = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("To: ");
        rowTop.Cells[0].AddParagraph(oModOrder.GetSetbpdesc);
        rowTop.Cells[0].AddParagraph(oModOrder.GetSetbpaddress);
        rowTop.Cells[0].AddParagraph("Contact: " + oModOrder.GetSetbpcontact);
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph("Support: ");
        rowTop.Cells[1].AddParagraph("HAZZARUL ANAS HALIM");
        rowTop.Cells[1].AddParagraph("SALES & SUPPORT");
        rowTop.Cells[1].AddParagraph("Contact: +6017-552 4447");
        rowTop.Cells[1].Borders.Left.Visible   = false;
        rowTop.Cells[1].Borders.Right.Visible  = false;
        rowTop.Cells[1].Borders.Bottom.Visible = false;
        rowTop.Cells[1].MergeRight             = 1;
        rowTop.Cells[2].Borders.Right.Visible  = false;

        // Create the item table
        MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();
        table.Style               = "Table";
        table.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        table.Borders.Width       = 0.25;
        table.Borders.Left.Width  = 0.5;
        table.Borders.Right.Width = 0.5;
        table.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column column = table.AddColumn("0.5cm");

        column.Format.Alignment = ParagraphAlignment.Center;

        column = table.AddColumn("3cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("4cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Center;

        column = table.AddColumn("1cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("1.5cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        // Create the header of the table
        Row row = table.AddRow();

        row.HeadingFormat    = true;
        row.Format.Alignment = ParagraphAlignment.Center;
        row.Format.Font.Bold = true;
        row.Shading.Color    = MigraDoc.DocumentObjectModel.Colors.LightGray;
        row.Cells[0].AddParagraph("NO.");
        row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[0].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[1].AddParagraph("ITEM NO");
        row.Cells[1].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[1].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[2].AddParagraph("DESCRIPTION");
        row.Cells[2].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[2].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[3].AddParagraph("UNIT PRICE");
        row.Cells[3].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[3].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[4].AddParagraph("DISCOUNT");
        row.Cells[4].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[4].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[5].AddParagraph("QTY");
        row.Cells[5].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[5].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[6].AddParagraph("PRICE");
        row.Cells[6].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[6].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[7].AddParagraph("TAX");
        row.Cells[7].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[7].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[8].AddParagraph("TOTAL");
        row.Cells[8].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[8].VerticalAlignment = VerticalAlignment.Bottom;

        for (int i = 0; i < lsOrderLineItem.Count; i++)
        {
            MainModel modOrdDet = (MainModel)lsOrderLineItem[i];

            // Each item fills two rows
            Row row1 = table.AddRow();
            row1.Height     = "2cm";
            row1.TopPadding = 1.5;
            //row1.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row1.Cells[0].Format.Alignment = ParagraphAlignment.Center;
            row1.Cells[1].Format.Alignment = ParagraphAlignment.Left;
            row1.Cells[2].Format.Alignment = ParagraphAlignment.Left;
            row1.Cells[3].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[4].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[5].Format.Alignment = ParagraphAlignment.Center;
            row1.Cells[6].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[7].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[8].Format.Alignment = ParagraphAlignment.Right;

            row1.Cells[0].AddParagraph((i + 1).ToString());
            row1.Cells[1].AddParagraph(modOrdDet.GetSetitemno);
            row1.Cells[2].AddParagraph(modOrdDet.GetSetitemdesc);
            row1.Cells[3].AddParagraph(modOrdDet.GetSetunitprice.ToString("#,##0.00"));
            row1.Cells[4].AddParagraph(modOrdDet.GetSetdiscamount.ToString("#,##0.00"));
            row1.Cells[5].AddParagraph(modOrdDet.GetSetquantity.ToString());
            row1.Cells[6].AddParagraph(modOrdDet.GetSetorderprice.ToString("#,##0.00"));
            row1.Cells[7].AddParagraph(modOrdDet.GetSettaxamount.ToString("#,##0.00"));
            row1.Cells[8].AddParagraph(modOrdDet.GetSettotalprice.ToString("#,##0.00"));

            if (i > 0 && ((i + 1) % 6) == 0)
            {
                row1.Cells[0].Borders.Bottom.Visible = true;
                row1.Cells[1].Borders.Bottom.Visible = true;
                row1.Cells[2].Borders.Bottom.Visible = true;
                row1.Cells[3].Borders.Bottom.Visible = true;
                row1.Cells[4].Borders.Bottom.Visible = true;
                row1.Cells[5].Borders.Bottom.Visible = true;
                row1.Cells[6].Borders.Bottom.Visible = true;
                row1.Cells[7].Borders.Bottom.Visible = true;
                row1.Cells[8].Borders.Bottom.Visible = true;
            }
            else
            {
                row1.Cells[0].Borders.Bottom.Visible = false;
                row1.Cells[1].Borders.Bottom.Visible = false;
                row1.Cells[2].Borders.Bottom.Visible = false;
                row1.Cells[3].Borders.Bottom.Visible = false;
                row1.Cells[4].Borders.Bottom.Visible = false;
                row1.Cells[5].Borders.Bottom.Visible = false;
                row1.Cells[6].Borders.Bottom.Visible = false;
                row1.Cells[7].Borders.Bottom.Visible = false;
                row1.Cells[8].Borders.Bottom.Visible = false;
            }
        }
        if ((lsOrderLineItem.Count % 6) > 0)
        {
            int totalremainingrow = 6 - (lsOrderLineItem.Count % 6);
            for (int j = 0; j < totalremainingrow; j++)
            {
                Row rowRemain = table.AddRow();
                rowRemain.Height = "2cm";
                rowRemain.Cells[0].AddParagraph();
                rowRemain.Cells[1].AddParagraph();
                rowRemain.Cells[2].AddParagraph();
                rowRemain.Cells[3].AddParagraph();
                rowRemain.Cells[4].AddParagraph();
                rowRemain.Cells[5].AddParagraph();
                rowRemain.Cells[6].AddParagraph();
                rowRemain.Cells[7].AddParagraph();
                rowRemain.Cells[8].AddParagraph();

                if (j == (totalremainingrow - 1))
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = true;
                    rowRemain.Cells[1].Borders.Bottom.Visible = true;
                    rowRemain.Cells[2].Borders.Bottom.Visible = true;
                    rowRemain.Cells[3].Borders.Bottom.Visible = true;
                    rowRemain.Cells[4].Borders.Bottom.Visible = true;
                    rowRemain.Cells[5].Borders.Bottom.Visible = true;
                    rowRemain.Cells[6].Borders.Bottom.Visible = true;
                    rowRemain.Cells[7].Borders.Bottom.Visible = true;
                    rowRemain.Cells[8].Borders.Bottom.Visible = true;
                }
                else if (j > 0 && (j % (totalremainingrow - 1)) == 0)
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = true;
                    rowRemain.Cells[1].Borders.Bottom.Visible = true;
                    rowRemain.Cells[2].Borders.Bottom.Visible = true;
                    rowRemain.Cells[3].Borders.Bottom.Visible = true;
                    rowRemain.Cells[4].Borders.Bottom.Visible = true;
                    rowRemain.Cells[5].Borders.Bottom.Visible = true;
                    rowRemain.Cells[6].Borders.Bottom.Visible = true;
                    rowRemain.Cells[7].Borders.Bottom.Visible = true;
                    rowRemain.Cells[8].Borders.Bottom.Visible = true;
                }
                else
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = false;
                    rowRemain.Cells[1].Borders.Bottom.Visible = false;
                    rowRemain.Cells[2].Borders.Bottom.Visible = false;
                    rowRemain.Cells[3].Borders.Bottom.Visible = false;
                    rowRemain.Cells[4].Borders.Bottom.Visible = false;
                    rowRemain.Cells[5].Borders.Bottom.Visible = false;
                    rowRemain.Cells[6].Borders.Bottom.Visible = false;
                    rowRemain.Cells[7].Borders.Bottom.Visible = false;
                    rowRemain.Cells[8].Borders.Bottom.Visible = false;
                }
            }
        }

        /*
         * Row rowTax = table.AddRow();
         * //rowTax.Height = "1cm";
         * rowTax.Cells[0].AddParagraph();
         * rowTax.Cells[0].Borders.Left.Visible = false;
         * rowTax.Cells[0].Borders.Right.Visible = false;
         * rowTax.Cells[0].Borders.Bottom.Visible = false;
         * rowTax.Cells[0].MergeRight = 6;
         * rowTax.Cells[7].AddParagraph("TAX");
         * rowTax.Cells[7].Format.Alignment = ParagraphAlignment.Left;
         * rowTax.Cells[8].AddParagraph(oModOrder.GetSettaxamount.ToString("#,##0.00"));
         * rowTax.Cells[8].Format.Alignment = ParagraphAlignment.Right;
         */

        Row rowTot = table.AddRow();

        rowTot.Height           = "1cm";
        rowTot.Format.Font.Bold = true;
        rowTot.Cells[0].AddParagraph();
        rowTot.Cells[0].Borders.Left.Visible   = false;
        rowTot.Cells[0].Borders.Right.Visible  = false;
        rowTot.Cells[0].Borders.Bottom.Visible = false;
        rowTot.Cells[0].MergeRight             = 6;

        /*
         * rowTot.Cells[1].AddParagraph();
         * rowTot.Cells[1].Borders.Left.Visible = false;
         * rowTot.Cells[2].AddParagraph();
         * rowTot.Cells[2].Borders.Left.Visible = false;
         * rowTot.Cells[3].AddParagraph();
         * rowTot.Cells[3].Borders.Left.Visible = false;
         * rowTot.Cells[4].AddParagraph();
         * rowTot.Cells[4].Borders.Left.Visible = false;
         * rowTot.Cells[5].AddParagraph();
         * rowTot.Cells[5].Borders.Left.Visible = false;
         * rowTot.Cells[6].AddParagraph();
         * rowTot.Cells[6].Borders.Left.Visible = false;
         */
        rowTot.Cells[6].Borders.Right.Visible = false;

        rowTot.Cells[7].AddParagraph("GRAND TOTAL");
        rowTot.Cells[7].Format.Alignment     = ParagraphAlignment.Left;
        rowTot.Cells[7].VerticalAlignment    = VerticalAlignment.Center;
        rowTot.Cells[7].Borders.Left.Visible = false;
        //rowTot.Cells[7].Borders.Right.Visible = false;
        rowTot.Cells[7].Borders.Bottom.Visible = false;

        rowTot.Cells[8].AddParagraph(oModOrder.GetSettotalamount.ToString("#,##0.00"));
        rowTot.Cells[8].Format.Alignment  = ParagraphAlignment.Right;
        rowTot.Cells[8].VerticalAlignment = VerticalAlignment.Center;

        //footer.AddText("Footer");
        //footer.Format.Font.Size = 9;
        //footer.Format.Alignment = ParagraphAlignment.Center;

        // Create the item table for footer
        //MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.Headers.Primary.AddImage(logo_lima);
        MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.Footers.Primary.AddTable();
        //MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.AddTable();
        tblBtm.Style               = "Table";
        tblBtm.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        tblBtm.Borders.Width       = 0.25;
        tblBtm.Borders.Left.Width  = 0.5;
        tblBtm.Borders.Right.Width = 0.5;
        tblBtm.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column colTblBtm = tblBtm.AddColumn("6cm");

        colTblBtm.Format.Alignment = ParagraphAlignment.Left;
        colTblBtm = tblBtm.AddColumn("6cm");
        colTblBtm.Format.Alignment = ParagraphAlignment.Left;
        colTblBtm = tblBtm.AddColumn("6cm");
        colTblBtm.Format.Alignment = ParagraphAlignment.Left;

        Row rowTblBtm = tblBtm.AddRow();

        rowTblBtm.Borders.Left.Visible  = false;
        rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible   = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Remarks:");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        //rowTblBtm.Borders.Left.Visible = false;
        //rowTblBtm.Borders.Right.Visible = false;
        //rowTblBtm.Borders.Top.Visible = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph(oModOrder.GetSetorderremarks);
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm        = tblBtm.AddRow();
        rowTblBtm.Height = "2cm";
        //rowTblBtm.Borders.Left.Visible = false;
        //rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph();
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("1. Once the order is confirmed, any cancellation and changes of the order is not allowed.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("2. Delivery lead time is 3 working days upon receive the confirmed Work Order & advert content.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("3. All prices are subject to change without any prior notices.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible  = false;
        rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible   = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph();
        rowTblBtm.Cells[0].MergeRight = 1;
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Format.Font.Bold = true;
        rowTblBtm.Cells[0].AddParagraph(oModOrder.GetSetbpdesc);
        //rowTblBtm.Cells[0].Borders.Top.Visible = true;
        rowTblBtm.Cells[1].AddParagraph("CAPITAL DIGITAL");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Confirmed By: (Please stamp and sign)");
        rowTblBtm.Cells[1].AddParagraph("Checked By:");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible          = false;
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm.Height = "2cm";
        rowTblBtm        = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Name:");
        rowTblBtm.Cells[1].AddParagraph("Name: HAZZARUL ANAS HALIM");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Designation:");
        rowTblBtm.Cells[1].AddParagraph("Designation: Sales & Marketing Advisor");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Cells[0].AddParagraph("Date:");
        rowTblBtm.Cells[1].AddParagraph("Date:");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;

        // Create a renderer for PDF that uses Unicode font encoding
        PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

        // Set the MigraDoc document
        pdfRenderer.Document = doc;

        // Create the PDF document
        pdfRenderer.RenderDocument();

        // Save the document...
        string pdfFilename = sOrderNo + ".pdf";
        string file        = Server.MapPath("~/App_Data/" + pdfFilename);
        //string file = HttpContext.Current.Server.MapPath("~/pdf/" + pdfFilename);
        //string file = "C:/TEMP/" + pdfFilename;

        // ...and start a viewer //
        //pdfRenderer.Save(file);
        //Process.Start(file);

        // Send PDF to browser //
        MemoryStream stream = new MemoryStream();

        pdfRenderer.Save(stream, false);
        Response.Clear();
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-length", stream.Length.ToString());
        Response.BinaryWrite(stream.ToArray());
        Response.Flush();
        stream.Close();
        Response.End();

        //download file //
        //Response.ContentType = "Application/pdf";
        //Response.AppendHeader("Content-Disposition", "attachment; filename=" + pdfFilename);
        //Response.TransmitFile(file);
        //Response.End();
    }
Exemple #14
0
    private void generatePDFFile()
    {
        // Create a MigraDoc document
        Document doc = new Document();

        doc.Info.Title   = "Pesanan Agihan";
        doc.Info.Subject = "Order No:" + oModOrder.GetSetorderno;
        doc.Info.Author  = "ZMartPartner System";

        //set page orientation
        doc.DefaultPageSetup.Orientation    = MigraDoc.DocumentObjectModel.Orientation.Portrait;
        doc.DefaultPageSetup.TopMargin      = "7.5cm"; //120
        doc.DefaultPageSetup.BottomMargin   = "8.5cm"; //150
        doc.DefaultPageSetup.LeftMargin     = 40;
        doc.DefaultPageSetup.RightMargin    = 40;
        doc.DefaultPageSetup.HeaderDistance = "1.5cm"; //20
        doc.DefaultPageSetup.FooterDistance = "1cm";   //20

        MigraDoc.DocumentObjectModel.Style style = doc.Styles["Normal"];
        // Because all styles are derived from Normal, the next line changes the
        // font of the whole document. Or, more exactly, it changes the font of
        // all styles and paragraphs that do not redefine the font.
        style.Font.Name = "Verdana";

        // Create a new style called Table based on style Normal
        style           = doc.Styles.AddStyle("Table", "Normal");
        style.Font.Name = "Verdana";
        style.Font.Name = "Arial";
        style.Font.Size = 8;

        // Each MigraDoc document needs at least one section.
        Section section = doc.AddSection();

        // Put 1st logo in the header
        string logo_lima = Server.MapPath("~/images/" + modCompInfo.GetSetcomp_logo1);

        MigraDoc.DocumentObjectModel.Shapes.Image image = section.Headers.Primary.AddImage(logo_lima);
        image.Height             = "1cm";
        image.LockAspectRatio    = true;
        image.RelativeVertical   = RelativeVertical.Line;
        image.RelativeHorizontal = RelativeHorizontal.Margin;
        image.Top              = ShapePosition.Top;
        image.Left             = ShapePosition.Right;
        image.WrapFormat.Style = WrapStyle.Through;

        // Put 2nd logo in the header
        string logo_mod = Server.MapPath("~/images/" + modCompInfo.GetSetcomp_logo2);

        MigraDoc.DocumentObjectModel.Shapes.Image image2 = section.Headers.Primary.AddImage(logo_mod);
        image2.Height             = "1cm";
        image2.LockAspectRatio    = true;
        image2.RelativeVertical   = RelativeVertical.Line;
        image2.RelativeHorizontal = RelativeHorizontal.Margin;
        image2.Top              = ShapePosition.Top;
        image2.Left             = ShapePosition.Left;
        image2.WrapFormat.Style = WrapStyle.Through;

        // Create Header
        Paragraph header = section.Headers.Primary.AddParagraph();

        header.AddText("PESANAN AGIHAN");
        header.Format.Font.Size = 12;
        header.Format.Font.Bold = true;
        header.Format.Alignment = ParagraphAlignment.Center;

        // Create main section for Sales Order
        //Paragraph main = section.AddParagraph();
        // main = section.AddParagraph();
        //main.Format.SpaceBefore = 1;

        // Create the item table for header
        //MigraDoc.DocumentObjectModel.Tables.Table tableTop = section.AddTable();
        MigraDoc.DocumentObjectModel.Tables.Table tableTop = section.Headers.Primary.AddTable();
        tableTop.Style               = "Table";
        tableTop.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        tableTop.Borders.Width       = 0.25;
        tableTop.Borders.Left.Width  = 0.5;
        tableTop.Borders.Right.Width = 0.5;
        tableTop.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column columnTop = tableTop.AddColumn("8cm");

        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("3cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("7cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;

        Row rowTop = tableTop.AddRow();

        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible  = false;
        rowTop.Borders.Right.Visible = false;
        rowTop.Borders.Top.Visible   = false;
        //rowTop.Borders.Bottom.Visible = false;
        rowTop.Cells[0].AddParagraph();
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph();
        rowTop.Cells[2].AddParagraph();


        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("Daripada:");
        rowTop.Cells[0].AddParagraph(modCompInfo.GetSetcomp_name);
        rowTop.Cells[0].AddParagraph(modCompInfo.GetSetcomp_address);
        rowTop.Cells[0].AddParagraph(modCompInfo.GetSetcomp_website);
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Top.Visible    = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[0].MergeDown = 5;
        rowTop.Cells[1].AddParagraph("No. Pesanan");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetorderno);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Tarikh");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetorderdate);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Jenis");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetordertype);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Pejabat Agihan");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + modCompInfo.GetSetcomp_name);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Pegawai Agihan");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetusername);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph("No. Dihubungi");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + modCompInfo.GetSetcomp_contactno);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("");
        rowTop.Cells[0].MergeRight             = 2;
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Top.Visible    = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[2].Borders.Right.Visible  = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("Kepada: ");
        rowTop.Cells[0].AddParagraph(oModOrder.GetSetbpdesc);
        rowTop.Cells[0].AddParagraph(oModOrder.GetSetbpaddress);
        rowTop.Cells[0].AddParagraph("Hubungi: " + oModOrder.GetSetbpcontact);
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph("Support: ");
        rowTop.Cells[1].AddParagraph(modCompInfo.GetSetcomp_contact);
        rowTop.Cells[1].AddParagraph("SALES & SUPPORT");
        rowTop.Cells[1].AddParagraph("Hubungi: " + modCompInfo.GetSetcomp_contactno);
        rowTop.Cells[1].Borders.Left.Visible   = false;
        rowTop.Cells[1].Borders.Right.Visible  = false;
        rowTop.Cells[1].Borders.Bottom.Visible = false;
        rowTop.Cells[1].MergeRight             = 1;
        rowTop.Cells[2].Borders.Right.Visible  = false;

        // Create the item table
        MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();
        table.Style               = "Table";
        table.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        table.Borders.Width       = 0.25;
        table.Borders.Left.Width  = 0.5;
        table.Borders.Right.Width = 0.5;
        table.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column column = table.AddColumn("0.5cm");

        column.Format.Alignment = ParagraphAlignment.Center;

        column = table.AddColumn("3cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("4cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Center;

        column = table.AddColumn("1cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("1.5cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        // Create the header of the table
        Row row = table.AddRow();

        row.HeadingFormat    = true;
        row.Format.Alignment = ParagraphAlignment.Center;
        row.Format.Font.Bold = true;
        row.Shading.Color    = MigraDoc.DocumentObjectModel.Colors.LightGray;
        row.Cells[0].AddParagraph("#");
        row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[0].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[1].AddParagraph("NO. ITEM");
        row.Cells[1].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[1].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[2].AddParagraph("KETERANGAN");
        row.Cells[2].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[2].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[3].AddParagraph("HARGA UNIT");
        row.Cells[3].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[3].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[4].AddParagraph("DISKAUN");
        row.Cells[4].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[4].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[5].AddParagraph("QTY");
        row.Cells[5].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[5].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[6].AddParagraph("HARGA");
        row.Cells[6].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[6].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[7].AddParagraph("TAX");
        row.Cells[7].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[7].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[8].AddParagraph("JUMLAH");
        row.Cells[8].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[8].VerticalAlignment = VerticalAlignment.Bottom;

        for (int i = 0; i < lsOrderLineItem.Count; i++)
        {
            MainModel modOrdDet = (MainModel)lsOrderLineItem[i];

            // Each item fills two rows
            Row row1 = table.AddRow();
            row1.Height     = "2cm";
            row1.TopPadding = 1.5;
            //row1.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row1.Cells[0].Format.Alignment = ParagraphAlignment.Center;
            row1.Cells[1].Format.Alignment = ParagraphAlignment.Left;
            row1.Cells[2].Format.Alignment = ParagraphAlignment.Left;
            row1.Cells[3].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[4].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[5].Format.Alignment = ParagraphAlignment.Center;
            row1.Cells[6].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[7].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[8].Format.Alignment = ParagraphAlignment.Right;

            row1.Cells[0].AddParagraph((i + 1).ToString());
            row1.Cells[1].AddParagraph(modOrdDet.GetSetitemno);
            row1.Cells[2].AddParagraph(modOrdDet.GetSetitemdesc);
            row1.Cells[3].AddParagraph(modOrdDet.GetSetunitprice.ToString("#,##0.00"));
            row1.Cells[4].AddParagraph(modOrdDet.GetSetdiscamount.ToString("#,##0.00"));
            row1.Cells[5].AddParagraph(modOrdDet.GetSetquantity.ToString());
            row1.Cells[6].AddParagraph(modOrdDet.GetSetorderprice.ToString("#,##0.00"));
            row1.Cells[7].AddParagraph(modOrdDet.GetSettaxamount.ToString("#,##0.00"));
            row1.Cells[8].AddParagraph(modOrdDet.GetSettotalprice.ToString("#,##0.00"));

            if (i > 0 && ((i + 1) % 6) == 0)
            {
                row1.Cells[0].Borders.Bottom.Visible = true;
                row1.Cells[1].Borders.Bottom.Visible = true;
                row1.Cells[2].Borders.Bottom.Visible = true;
                row1.Cells[3].Borders.Bottom.Visible = true;
                row1.Cells[4].Borders.Bottom.Visible = true;
                row1.Cells[5].Borders.Bottom.Visible = true;
                row1.Cells[6].Borders.Bottom.Visible = true;
                row1.Cells[7].Borders.Bottom.Visible = true;
                row1.Cells[8].Borders.Bottom.Visible = true;
            }
            else
            {
                row1.Cells[0].Borders.Bottom.Visible = false;
                row1.Cells[1].Borders.Bottom.Visible = false;
                row1.Cells[2].Borders.Bottom.Visible = false;
                row1.Cells[3].Borders.Bottom.Visible = false;
                row1.Cells[4].Borders.Bottom.Visible = false;
                row1.Cells[5].Borders.Bottom.Visible = false;
                row1.Cells[6].Borders.Bottom.Visible = false;
                row1.Cells[7].Borders.Bottom.Visible = false;
                row1.Cells[8].Borders.Bottom.Visible = false;
            }
        }
        if ((lsOrderLineItem.Count % 6) > 0)
        {
            int totalremainingrow = 6 - (lsOrderLineItem.Count % 6);
            for (int j = 0; j < totalremainingrow; j++)
            {
                Row rowRemain = table.AddRow();
                rowRemain.Height = "2cm";
                rowRemain.Cells[0].AddParagraph();
                rowRemain.Cells[1].AddParagraph();
                rowRemain.Cells[2].AddParagraph();
                rowRemain.Cells[3].AddParagraph();
                rowRemain.Cells[4].AddParagraph();
                rowRemain.Cells[5].AddParagraph();
                rowRemain.Cells[6].AddParagraph();
                rowRemain.Cells[7].AddParagraph();
                rowRemain.Cells[8].AddParagraph();

                if (j == (totalremainingrow - 1))
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = true;
                    rowRemain.Cells[1].Borders.Bottom.Visible = true;
                    rowRemain.Cells[2].Borders.Bottom.Visible = true;
                    rowRemain.Cells[3].Borders.Bottom.Visible = true;
                    rowRemain.Cells[4].Borders.Bottom.Visible = true;
                    rowRemain.Cells[5].Borders.Bottom.Visible = true;
                    rowRemain.Cells[6].Borders.Bottom.Visible = true;
                    rowRemain.Cells[7].Borders.Bottom.Visible = true;
                    rowRemain.Cells[8].Borders.Bottom.Visible = true;
                }
                else if (j > 0 && (j % (totalremainingrow - 1)) == 0)
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = true;
                    rowRemain.Cells[1].Borders.Bottom.Visible = true;
                    rowRemain.Cells[2].Borders.Bottom.Visible = true;
                    rowRemain.Cells[3].Borders.Bottom.Visible = true;
                    rowRemain.Cells[4].Borders.Bottom.Visible = true;
                    rowRemain.Cells[5].Borders.Bottom.Visible = true;
                    rowRemain.Cells[6].Borders.Bottom.Visible = true;
                    rowRemain.Cells[7].Borders.Bottom.Visible = true;
                    rowRemain.Cells[8].Borders.Bottom.Visible = true;
                }
                else
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = false;
                    rowRemain.Cells[1].Borders.Bottom.Visible = false;
                    rowRemain.Cells[2].Borders.Bottom.Visible = false;
                    rowRemain.Cells[3].Borders.Bottom.Visible = false;
                    rowRemain.Cells[4].Borders.Bottom.Visible = false;
                    rowRemain.Cells[5].Borders.Bottom.Visible = false;
                    rowRemain.Cells[6].Borders.Bottom.Visible = false;
                    rowRemain.Cells[7].Borders.Bottom.Visible = false;
                    rowRemain.Cells[8].Borders.Bottom.Visible = false;
                }
            }
        }

        /*
         * Row rowTax = table.AddRow();
         * //rowTax.Height = "1cm";
         * rowTax.Cells[0].AddParagraph();
         * rowTax.Cells[0].Borders.Left.Visible = false;
         * rowTax.Cells[0].Borders.Right.Visible = false;
         * rowTax.Cells[0].Borders.Bottom.Visible = false;
         * rowTax.Cells[0].MergeRight = 6;
         * rowTax.Cells[7].AddParagraph("TAX");
         * rowTax.Cells[7].Format.Alignment = ParagraphAlignment.Left;
         * rowTax.Cells[8].AddParagraph(oModOrder.GetSettaxamount.ToString("#,##0.00"));
         * rowTax.Cells[8].Format.Alignment = ParagraphAlignment.Right;
         */

        Row rowTot = table.AddRow();

        rowTot.Height           = "1cm";
        rowTot.Format.Font.Bold = true;
        rowTot.Cells[0].AddParagraph();
        rowTot.Cells[0].Borders.Left.Visible   = false;
        rowTot.Cells[0].Borders.Right.Visible  = false;
        rowTot.Cells[0].Borders.Bottom.Visible = false;
        rowTot.Cells[0].MergeRight             = 6;

        /*
         * rowTot.Cells[1].AddParagraph();
         * rowTot.Cells[1].Borders.Left.Visible = false;
         * rowTot.Cells[2].AddParagraph();
         * rowTot.Cells[2].Borders.Left.Visible = false;
         * rowTot.Cells[3].AddParagraph();
         * rowTot.Cells[3].Borders.Left.Visible = false;
         * rowTot.Cells[4].AddParagraph();
         * rowTot.Cells[4].Borders.Left.Visible = false;
         * rowTot.Cells[5].AddParagraph();
         * rowTot.Cells[5].Borders.Left.Visible = false;
         * rowTot.Cells[6].AddParagraph();
         * rowTot.Cells[6].Borders.Left.Visible = false;
         */
        rowTot.Cells[6].Borders.Right.Visible = false;

        rowTot.Cells[7].AddParagraph("JUMLAH BESAR");
        rowTot.Cells[7].Format.Alignment     = ParagraphAlignment.Left;
        rowTot.Cells[7].VerticalAlignment    = VerticalAlignment.Center;
        rowTot.Cells[7].Borders.Left.Visible = false;
        //rowTot.Cells[7].Borders.Right.Visible = false;
        rowTot.Cells[7].Borders.Bottom.Visible = false;

        rowTot.Cells[8].AddParagraph(oModOrder.GetSettotalamount.ToString("#,##0.00"));
        rowTot.Cells[8].Format.Alignment  = ParagraphAlignment.Right;
        rowTot.Cells[8].VerticalAlignment = VerticalAlignment.Center;

        //footer.AddText("Footer");
        //footer.Format.Font.Size = 9;
        //footer.Format.Alignment = ParagraphAlignment.Center;

        // Create the item table for footer
        //MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.Headers.Primary.AddImage(logo_lima);
        MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.Footers.Primary.AddTable();
        //MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.AddTable();
        tblBtm.Style               = "Table";
        tblBtm.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        tblBtm.Borders.Width       = 0.25;
        tblBtm.Borders.Left.Width  = 0.5;
        tblBtm.Borders.Right.Width = 0.5;
        tblBtm.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column colTblBtm = tblBtm.AddColumn("6cm");

        colTblBtm.Format.Alignment = ParagraphAlignment.Left;
        colTblBtm = tblBtm.AddColumn("6cm");
        colTblBtm.Format.Alignment = ParagraphAlignment.Left;
        colTblBtm = tblBtm.AddColumn("6cm");
        colTblBtm.Format.Alignment = ParagraphAlignment.Left;

        Row rowTblBtm = tblBtm.AddRow();

        rowTblBtm.Borders.Left.Visible  = false;
        rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible   = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Catatan:");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        //rowTblBtm.Borders.Left.Visible = false;
        //rowTblBtm.Borders.Right.Visible = false;
        //rowTblBtm.Borders.Top.Visible = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph(oModOrder.GetSetorderremarks);
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm        = tblBtm.AddRow();
        rowTblBtm.Height = "2cm";
        //rowTblBtm.Borders.Left.Visible = false;
        //rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph();
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("1. Setelah Pesanan Agihan disahkan, sebarang pembatalan dan perubahan pesanan tidak dibenarkan.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("2. Penghantaran item Pesanan Agihan akan dilakukan setelah menerima pengesahan daripada Pejabat Agihan.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("3. Perubahan pada harga item Pesanan Agihan adalah tertakluk kepada terma & syarat tanpa sebarang notis.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible  = false;
        rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible   = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph();
        rowTblBtm.Cells[0].MergeRight = 1;
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Format.Font.Bold = true;
        rowTblBtm.Cells[0].AddParagraph(oModOrder.GetSetbpdesc);
        //rowTblBtm.Cells[0].Borders.Top.Visible = true;
        rowTblBtm.Cells[1].AddParagraph(modCompInfo.GetSetcomp_name);
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Disahkan Oleh: (Cop dan Tandatangan)");
        rowTblBtm.Cells[1].AddParagraph("Disemak Oleh:");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible          = false;
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm.Height = "2cm";
        rowTblBtm        = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Nama:");
        rowTblBtm.Cells[1].AddParagraph("Nama:");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Jawatan:");
        rowTblBtm.Cells[1].AddParagraph("Jawatan: Pegawai Agihan & Pemasaran");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Cells[0].AddParagraph("Tarikh:");
        rowTblBtm.Cells[1].AddParagraph("Tarikh:");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;

        // Create a renderer for PDF that uses Unicode font encoding
        PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

        // Set the MigraDoc document
        pdfRenderer.Document = doc;

        // Create the PDF document
        pdfRenderer.RenderDocument();

        // Save the document...
        string pdfFilename = sOrderNo + ".pdf";
        string file        = Server.MapPath("~/App_Data/" + pdfFilename);
        //string file = HttpContext.Current.Server.MapPath("~/pdf/" + pdfFilename);
        //string file = "C:/TEMP/" + pdfFilename;

        // ...and start a viewer //
        //pdfRenderer.Save(file);
        //Process.Start(file);

        // Send PDF to browser //
        MemoryStream stream = new MemoryStream();

        pdfRenderer.Save(stream, false);
        Response.Clear();
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-length", stream.Length.ToString());
        Response.BinaryWrite(stream.ToArray());
        Response.Flush();
        stream.Close();
        Response.End();

        //download file //
        //Response.ContentType = "Application/pdf";
        //Response.AppendHeader("Content-Disposition", "attachment; filename=" + pdfFilename);
        //Response.TransmitFile(file);
        //Response.End();
    }
Exemple #15
0
        /// <summary>
        /// Creates the static parts of the invoice.
        /// </summary>
        void CreatePage()
        {
            // Each MigraDoc document needs at least one section.
            Section section = this.document.AddSection();

            // Put a logo in the header
            Image image = section.AddImage(path);

            image.Top              = ShapePosition.Top;
            image.Left             = ShapePosition.Left;
            image.WrapFormat.Style = WrapStyle.Through;

            // Create footer
            Paragraph paragraph = section.Footers.Primary.AddParagraph();

            paragraph.AddText("Health And Social Services.");
            paragraph.Format.Font.Size = 9;
            paragraph.Format.Alignment = ParagraphAlignment.Center;

            // Create the text frame for the address
            this.addressFrame                    = section.AddTextFrame();
            this.addressFrame.Height             = "3.0cm";
            this.addressFrame.Width              = "7.0cm";
            this.addressFrame.Left               = ShapePosition.Left;
            this.addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.addressFrame.Top                = "5.0cm";
            this.addressFrame.RelativeVertical   = RelativeVertical.Page;

            // Put sender in address frame
            paragraph = this.addressFrame.AddParagraph("Karachi,Pakistan");
            paragraph.Format.Font.Name  = "Times New Roman";
            paragraph.Format.Font.Size  = 7;
            paragraph.Format.SpaceAfter = 3;

            // Add the print date field
            paragraph = section.AddParagraph();
            paragraph.Format.SpaceBefore = "6cm";
            paragraph.Style = "Reference";
            paragraph.AddFormattedText("Patients Detail", TextFormat.Bold);
            paragraph.AddTab();
            paragraph.AddText("Date, ");
            paragraph.AddDateField("dd.MM.yyyy");

            // Create the item table
            this.table                     = section.AddTable();
            this.table.Style               = "Table";
            this.table.Borders.Color       = TableBorder;
            this.table.Borders.Width       = 0.25;
            this.table.Borders.Left.Width  = 0.5;
            this.table.Borders.Right.Width = 0.5;
            this.table.Rows.LeftIndent     = 0;



            // Before you can add a row, you must define the columns
            Column column;

            foreach (DataColumn col in dt.Columns)
            {
                column = this.table.AddColumn(Unit.FromCentimeter(3));
                column.Format.Alignment = ParagraphAlignment.Center;
            }

            // Create the header of the table
            Row row = table.AddRow();

            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = TableBlue;


            for (int i = 0; i < dt.Columns.Count; i++)
            {
                row.Cells[i].AddParagraph(dt.Columns[i].ColumnName);
                row.Cells[i].Format.Font.Bold  = false;
                row.Cells[i].Format.Alignment  = ParagraphAlignment.Left;
                row.Cells[i].VerticalAlignment = VerticalAlignment.Bottom;
            }

            this.table.SetEdge(0, 0, dt.Columns.Count, 1, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
        }
Exemple #16
0
 /// <summary>
 /// Adds a new image to the collection.
 /// </summary>
 public Image AddImage(string name)
 {
     Image image = new Image();
     image.Name = name;
     Add(image);
     return image;
 }
Exemple #17
0
        /// <summary>Creates the graph.</summary>
        /// <param name="writer">The writer.</param>
        /// <param name="graphAndTable">The graph and table to convert to html.</param>
        /// <param name="workingDirectory">The working directory.</param>
        private void CreateGraphPDF(Section section, AutoDocumentation.GraphAndTable graphAndTable, string workingDirectory)
        {
            // Create a 2 column, 1 row table. Image in first cell, X/Y data in second cell.
            Table table = section.AddTable();

            table.Style           = "GraphAndTable";
            table.Rows.LeftIndent = graphAndTable.indent + "cm";

            Column column1 = table.AddColumn();

            column1.Width = "8cm";
            //column1.Format.Alignment = ParagraphAlignment.Right;
            Column column2 = table.AddColumn();

            column2.Width = "8cm";
            //column2.Format.Alignment = ParagraphAlignment.Right;
            Row row = table.AddRow();

            // Ensure graphs directory exists.
            string graphDirectory = Path.Combine(workingDirectory, "Graphs");

            Directory.CreateDirectory(graphDirectory);

            // Determine the name of the .png file to write.
            string PNGFileName = Path.Combine(graphDirectory,
                                              graphAndTable.xyPairs.Parent.Parent.Name + graphAndTable.xyPairs.Parent.Name + ".png");

            // Setup graph.
            GraphView graph = new GraphView(null);

            graph.Clear();

            // Create a line series.
            graph.DrawLineAndMarkers("", graphAndTable.xyPairs.X, graphAndTable.xyPairs.Y,
                                     Models.Graph.Axis.AxisType.Bottom, Models.Graph.Axis.AxisType.Left,
                                     System.Drawing.Color.Blue, Models.Graph.LineType.Solid, Models.Graph.MarkerType.None,
                                     Models.Graph.LineThicknessType.Normal, Models.Graph.MarkerSizeType.Normal, true);

            // Format the axes.
            graph.FormatAxis(Models.Graph.Axis.AxisType.Bottom, graphAndTable.xName, false, double.NaN, double.NaN, double.NaN);
            graph.FormatAxis(Models.Graph.Axis.AxisType.Left, graphAndTable.yName, false, double.NaN, double.NaN, double.NaN);
            graph.BackColor = OxyPlot.OxyColors.White;
            graph.FontSize  = 10;
            graph.Refresh();

            // Export graph to bitmap file.
            Bitmap image = new Bitmap(400, 250);

            graph.Export(ref image, false);
            image.Save(PNGFileName, System.Drawing.Imaging.ImageFormat.Png);
            MigraDoc.DocumentObjectModel.Shapes.Image image1 = row.Cells[0].AddImage(PNGFileName);

            // Add x/y data.
            Paragraph xyParagraph = row.Cells[1].AddParagraph();

            xyParagraph.Style = "xyStyle";
            AddFixedWidthText(xyParagraph, "X", 10);
            AddFixedWidthText(xyParagraph, "Y", 10);
            xyParagraph.AddLineBreak();
            for (int i = 0; i < graphAndTable.xyPairs.X.Length; i++)
            {
                AddFixedWidthText(xyParagraph, graphAndTable.xyPairs.X[i].ToString(), 10);
                AddFixedWidthText(xyParagraph, graphAndTable.xyPairs.Y[i].ToString(), 10);
                xyParagraph.AddLineBreak();
            }

            // Add an empty paragraph for spacing.
            Paragraph spacing = section.AddParagraph();
        }
Exemple #18
0
 private static MigraDoc.DocumentObjectModel.Shapes.Image BytesToPdfImage(byte[] bytes, out string pathName,
                                                                          bool autoRemove = true)
 {
     pathName = Utils.RandomFilePath(".png");
     using (var fs = new FileStream(pathName, FileMode.CreateNew))
     {
         fs.Write(bytes, 0, bytes.Count());
     }
     var res = new MigraDoc.DocumentObjectModel.Shapes.Image(pathName);
     if (autoRemove)
         File.Delete(pathName);
     return res;
 }
 // Shape
 internal virtual void VisitImage(Image image) { }
Exemple #20
0
        private void CreatePage()
        {
            // Each MigraDoc document needs at least one section.
            MigraDoc.DocumentObjectModel.Section section = this.document.AddSection();

            // Put a logo in the header
            Image image = section.Headers.Primary.AddImage("Image_Icons/logo1.png");

            image.Height             = "2.5cm";
            image.Width              = "5cm";
            image.LockAspectRatio    = true;
            image.RelativeVertical   = RelativeVertical.Line;
            image.RelativeHorizontal = RelativeHorizontal.Margin;
            image.Top              = ShapePosition.Top;
            image.Left             = ShapePosition.Right;
            image.WrapFormat.Style = WrapStyle.Through;

            // Create the text frame for the address
            this.addressFrame                    = section.AddTextFrame();
            this.addressFrame.Height             = "8.0cm";
            this.addressFrame.Width              = "10.0cm";
            this.addressFrame.Left               = ShapePosition.Left;
            this.addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.addressFrame.Top                = "4cm";
            this.addressFrame.RelativeVertical   = RelativeVertical.Page;

            this.PriceFrame                    = section.AddTextFrame();
            this.PriceFrame.Height             = "5.0cm";
            this.PriceFrame.Width              = "5.0cm";
            this.PriceFrame.Left               = ShapePosition.Right;
            this.PriceFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.PriceFrame.Top                = "4.0cm";
            this.PriceFrame.RelativeVertical   = RelativeVertical.Page;

            // Put sender in address frame
            //= addressFrame.AddParagraph("ul.Pralki 5, 13-342 Lodówka");
            //paragraph.Format.Font.Name = "Times New Roman";
            //paragraph.Format.Font.Size = 7;
            //paragraph.Format.SpaceAfter = 3;

            // Add the print date field
            MigraDoc.DocumentObjectModel.Paragraph paragraph = section.AddParagraph();
            paragraph.Format.SpaceBefore = "8cm";
            paragraph.Style = "Reference";
            paragraph.AddFormattedText($"Faktura nr {order.Date.Year}/{order.Id}", TextFormat.Bold);
            paragraph.AddTab();
            paragraph.AddText("Białystok, ");
            paragraph.AddDateField("dd.MM.yyyy");

            paragraph = section.Footers.Primary.AddParagraph();
            paragraph.AddText($"\u00a9 2021 RTV&AGD \n ul.Pralki 5, 13-342 Lodówka \n Data wydruku: {DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss")} ");
            paragraph.Format.Font.Size = 9;
            paragraph.Format.Alignment = ParagraphAlignment.Center;

            // Create the item table
            this.table                = section.AddTable();
            table.Format.Alignment    = ParagraphAlignment.Justify;
            table.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Black;
            table.Borders.Width       = 0.25;
            table.Borders.Left.Width  = 0.5;
            table.Borders.Right.Width = 0.5;
            table.Rows.LeftIndent     = 5;
            table.TopPadding          = 10;
            table.BottomPadding       = 10;

            // Before you can add a row, you must define the columns
            Column column = this.table.AddColumn("7.5cm");

            column.Format.Alignment = ParagraphAlignment.Center;

            column = this.table.AddColumn("1.5cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column = this.table.AddColumn("3.5cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column = this.table.AddColumn("3.5cm");
            column.Format.Alignment = ParagraphAlignment.Right;


            // Create the header of the table
            Row row = table.AddRow();

            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Left;
            row.Format.Font.Bold = true;
            row.Shading.Color    = TableBlue;
            row.Cells[0].AddParagraph("Nazwa");
            row.Cells[0].Format.Font.Bold  = true;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[0].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Center;

            row.Cells[1].AddParagraph("Ilość");
            row.Cells[1].Format.Alignment = ParagraphAlignment.Left;

            row.Cells[2].AddParagraph("Cena/szt");
            row.Cells[2].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[2].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Center;

            row.Cells[3].AddParagraph("Wartosc");
            row.Cells[3].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[3].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Center;



            this.table.SetEdge(0, 0, 4, 1, Edge.Box, BorderStyle.Single, 0.75, MigraDoc.DocumentObjectModel.Color.Empty);
        }
Exemple #21
0
        public void CreateDocument(List <Recipe> r)
        {
            for (int i = 0; i < r.Count; i++)
            {
                Patient  pa = GetPatient(r[i].PatientId);
                User     u  = GetUser(r[i].DoctorId);
                Medicine m  = GetMedicine(r[i].MedicineId);

                // Create a new MigraDoc document
                Document document = new Document();
                document.Info.Title = "Prescription";


                // Get the predefined style Normal.
                Style style = document.Styles["Normal"];
                style.Font.Name = "Verdana";
                style           = document.Styles[StyleNames.Header];
                style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right);
                style = document.Styles[StyleNames.Footer];
                style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center);
                style           = document.Styles.AddStyle("Table", "Normal");
                style.Font.Name = "Verdana";
                style.Font.Name = "Times New Roman";
                style.Font.Size = 9;
                style           = document.Styles.AddStyle("Reference", "Normal");
                style.ParagraphFormat.SpaceBefore = "5mm";
                style.ParagraphFormat.SpaceAfter  = "5mm";
                style.ParagraphFormat.TabStops.AddTabStop("16cm", TabAlignment.Right);


                // Each MigraDoc document needs at least one section.
                Section section = document.AddSection();

                // Put a logo in the header
                Image image = section.Headers.Primary.AddImage("../../Images/bikurofelogo.png");
                image.Height             = "2.5cm";
                image.LockAspectRatio    = true;
                image.RelativeVertical   = RelativeVertical.Line;
                image.RelativeHorizontal = RelativeHorizontal.Margin;
                image.Top              = ShapePosition.Top;
                image.Left             = ShapePosition.Right;
                image.WrapFormat.Style = WrapStyle.Through;


                Paragraph paragraph = section.Footers.Primary.AddParagraph();


                // Create the text frame for the address
                var addressFrame = section.AddTextFrame();
                addressFrame.Height = "3.0cm";
                //addressFrame.Width = "20cm";
                addressFrame.Left = ShapePosition.Center;
                addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;
                addressFrame.Top = "5.0cm";
                addressFrame.RelativeVertical = RelativeVertical.Page;

                // Put sender in address frame
                paragraph = addressFrame.AddParagraph(Reverse("מרשם"));
                paragraph.Format.Font.Name  = "Times New Roman";
                paragraph.Format.Font.Size  = 24;
                paragraph.Format.SpaceAfter = 3;


                // Add the print date field
                paragraph = section.AddParagraph();
                paragraph.Format.SpaceBefore = "8cm";
                paragraph.Style = "Reference";
                //paragraph.AddFormattedText("אאאאאאאאאאא", TextFormat.Bold);
                paragraph.AddTab();
                paragraph.AddText("Prescription, ");
                paragraph.AddDateField("dd.MM.yyyy");


                // Create the item table

                Table table = section.AddTable();
                table.Style = "Table";
                //table.Borders.Color = TableBorder;
                table.Borders.Width       = 0.25;
                table.Borders.Left.Width  = 0.5;
                table.Borders.Right.Width = 0.5;
                table.Rows.LeftIndent     = 0;


                // Before you can add a row, you must define the columns
                Column column = table.AddColumn("1cm");
                column.Format.Alignment = ParagraphAlignment.Center;
                column = table.AddColumn("2.0cm");
                column.Format.Alignment = ParagraphAlignment.Right;
                column = table.AddColumn("2cm");
                column.Format.Alignment = ParagraphAlignment.Right;
                column = table.AddColumn("2cm");
                column.Format.Alignment = ParagraphAlignment.Right;
                column = table.AddColumn("2cm");
                column.Format.Alignment = ParagraphAlignment.Center;
                column = table.AddColumn("2cm");
                column.Format.Alignment = ParagraphAlignment.Right;
                column = table.AddColumn("2cm");
                column.Format.Alignment = ParagraphAlignment.Right;
                column = table.AddColumn("2cm");
                column.Format.Alignment = ParagraphAlignment.Right;

                // Create the header of the table

                Row row = table.AddRow();
                row = table.AddRow();
                row.HeadingFormat    = true;
                row.Format.Alignment = ParagraphAlignment.Center;
                row.Format.Font.Bold = true;



                row.Cells[1].AddParagraph(Reverse("מספר פעמים ביום"));

                row.Cells[1].Format.Alignment = ParagraphAlignment.Right;

                row.Cells[2].AddParagraph(Reverse("משך זמן בימים"));

                row.Cells[2].Format.Alignment = ParagraphAlignment.Right;

                row.Cells[3].AddParagraph(Reverse("שם תרופה"));

                row.Cells[3].Format.Alignment = ParagraphAlignment.Right;

                row.Cells[4].AddParagraph(Reverse("מספר תרופה"));

                row.Cells[4].Format.Alignment = ParagraphAlignment.Right;

                row.Cells[5].AddParagraph(Reverse("שם רופא מטפל"));

                row.Cells[5].Format.Alignment = ParagraphAlignment.Right;

                row.Cells[6].AddParagraph(Reverse("מספר זהות"));

                row.Cells[6].Format.Alignment = ParagraphAlignment.Right;

                row.Cells[7].AddParagraph(Reverse("שם חולה"));

                row.Cells[7].Format.Alignment = ParagraphAlignment.Right;

                table.SetEdge(0, 0, 6, 2, Edge.Box, BorderStyle.Single, 0.75);

                Paragraph p = addressFrame.AddParagraph();

                p.AddLineBreak();

                p.AddLineBreak();

                // Each item fills two rows

                Row row1 = table.AddRow();
                row1.TopPadding = 1.5;
                row1.Cells[7].AddParagraph(Reverse(pa.Fname + " " + pa.Lname));
                row1.Cells[6].AddParagraph(pa.PatientId);
                row1.Cells[5].AddParagraph(Reverse(u.Fname + " " + u.Lname));
                row1.Cells[4].AddParagraph(m.Id);
                row1.Cells[3].AddParagraph(m.CommercialName);
                row1.Cells[2].AddParagraph(r[i].PeriodOfUse.ToString());
                row1.Cells[1].AddParagraph(r[i].QuantityPerDay.ToString());

                string pdfFilename = r[i].RecipeId + ".pdf";
                var    pdf         = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.None);
                pdf.Document = document;
                pdf.RenderDocument();
                pdf.Save(pdfFilename);
                Process.Start(pdfFilename);
            }
        }
Exemple #22
0
        public Document CreateTreningDOC()
        {
            Section section = document.AddSection();


            PageSettings(section);

            Paragraph p = section.AddParagraph();

            int[] imp = wyliczimpy(vugraph.Vu_ContractList_Open, vugraph.Vu_ContractList_Closed);
            int   impsns = 0, impsew = 0;

            for (int i = 0; i < Ustawienia.ilosc_rozdan; i++)
            {
                if (imp[i] > 0)
                {
                    impsns += imp[i];
                }
                else
                {
                    impsew -= imp[i];
                }
            }
            p.AddFormattedText("Rezultat meczu " + vugraph.team1Name + " - " + vugraph.team2Name + " " + impsns.ToString() + ":" + impsew.ToString(), font_tytuly);
            p.AddLineBreak();
            p.AddLineBreak();


            MakeTable33();
            //    MakeTable22();


            if (Ustawienia.deepfin)
            {
                lewy = InfoBridge.wylicz_DF(vugraph.rozklady);
            }
            for (int i = 0; i < Ustawienia.ilosc_rozdan - 1; i++)
            {
                // if (i != 0)
                document.AddSection();
                CreateBoard(i, vugraph.rozklady[i]);
                Paragraph pbreak = document.LastSection.AddParagraph();
                pbreak.AddLineBreak();
                pbreak.AddLineBreak();
                pbreak.AddFormattedText("Liczba lew do wzięcia : ", font_normal);
                pbreak.AddLineBreak();
                pbreak.AddLineBreak();
                if (Ustawienia.deepfin)
                {
                    CreateDF(i);
                }
                Paragraph p31 = document.LastSection.AddParagraph();
                p31.AddLineBreak();
                createClosed(i);
                createOpen(i);
                //  CreateBidding(i);

                //WriteLineKontrakt(vugraph.Vu_ContractList_Open[i], vugraph.Vu_ContractList_Closed[i]);

                //WriteCommentTitle();
            }

            MigraDoc.DocumentObjectModel.Shapes.Image reklama = new MigraDoc.DocumentObjectModel.Shapes.Image("images\\reklama.png");

            reklama.Height = Unit.FromCentimeter(8.0);
            reklama.Width  = Unit.FromCentimeter(12.0);

            reklama.WrapFormat.DistanceTop  = Unit.FromCentimeter(1.0);
            reklama.WrapFormat.DistanceLeft = Unit.FromCentimeter(2.0);

            document.LastSection.Add(reklama);
            document.UseCmykColor = true;

            document.Info.Author = "Maciej Bielawski";


            string ddl = MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToString(document);

            /*
             * RtfDocumentRenderer renderer = new RtfDocumentRenderer();
             *     renderer.Render(document,"Test.doc", null);
             *
             * Process.Start("Test.doc");*/

            return(document);
        }
Exemple #23
0
        public static void ConsignmentContract(string filePath, string logoPath, string title, string author, string subject, Address lelandsAddress, string lelandsSignaturePath, Address sellerAddress, string sellerEmail, string sellerSignaturePath, DateTime date, List <ConsignmentDetail> items, string contract)
        {
            Document document = new Document();

            document.Info.Title   = title;
            document.Info.Author  = author;
            document.Info.Subject = subject;

            Section section = document.AddSection();
            Table   table   = section.AddTable();

            table.Style = "Table";
            Column column = table.AddColumn("5cm");

            column.Format.Alignment = ParagraphAlignment.Left;
            column = table.AddColumn("6cm");
            column.Format.Alignment = ParagraphAlignment.Left;
            column = table.AddColumn("6cm");
            column.Format.Alignment = ParagraphAlignment.Left;

            Row row = table.AddRow();

            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            Image image = row.Cells[0].AddImage(logoPath);

            image.LockAspectRatio    = true;
            image.RelativeVertical   = RelativeVertical.Line;
            image.RelativeHorizontal = RelativeHorizontal.Margin;
            image.Top                      = ShapePosition.Top;
            image.Left                     = ShapePosition.Left;
            image.WrapFormat.Style         = WrapStyle.Through;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Top;
            row.Cells[0].MergeDown         = 5;

            Paragraph paragraph = row.Cells[1].AddParagraph();

            paragraph.AddText("Consignment Agreement Between");
            row.Cells[1].Format.Alignment = ParagraphAlignment.Center;
            row.Cells[1].MergeRight       = 1;

            row = table.AddRow();
            row.Cells[1].AddParagraph(lelandsAddress.FirstName);
            row.Cells[1].Format.Font.Size = 9;
            row.Cells[1].Format.Font.Bold = true;
            row.Cells[2].AddParagraph(string.Format("{0} {1}", sellerAddress.FirstName, sellerAddress.LastName));
            row.Cells[2].Format.Font.Size = 9;
            row.Cells[2].Format.Font.Bold = true;

            row = table.AddRow();
            row.Cells[1].AddParagraph(lelandsAddress.Address_1);
            row.Cells[1].Format.Font.Size = 9;
            row.Cells[2].AddParagraph(string.Format("{0} {1}", sellerAddress.Address_1, sellerAddress.Address_2));
            row.Cells[2].Format.Font.Size = 9;

            row = table.AddRow();
            row.Cells[1].AddParagraph(string.Format("{0}, {1} {2}", lelandsAddress.City, lelandsAddress.State, lelandsAddress.Zip));
            row.Cells[1].Format.Font.Size = 9;
            row.Cells[2].AddParagraph(string.Format("{0}, {1} {2}", sellerAddress.City, sellerAddress.State, sellerAddress.Zip));
            row.Cells[2].Format.Font.Size = 9;

            row = table.AddRow();
            row.Cells[1].AddParagraph(string.Format("Tel: {0}", lelandsAddress.HomePhone));
            row.Cells[1].Format.Font.Size = 9;
            row.Cells[2].AddParagraph(string.Format("Tel (Home): {0}", sellerAddress.HomePhone));
            row.Cells[2].Format.Font.Size = 9;

            row = table.AddRow();
            row.Cells[1].AddParagraph(string.Format("Fax: {0}", lelandsAddress.WorkPhone));
            row.Cells[1].Format.Font.Size = 9;
            row.Cells[2].AddParagraph(string.Format("Tel (Work): {0}", !string.IsNullOrWhiteSpace(sellerAddress.WorkPhone) ? sellerAddress.WorkPhone : "---"));
            row.Cells[2].Format.Font.Size = 9;

            row = table.AddRow();
            row.Cells[1].AddParagraph(lelandsAddress.LastName);
            row.Cells[1].Format.Font.Size = 9;
            row.Cells[2].AddParagraph(sellerEmail);
            row.Cells[2].Format.Font.Size = 9;


            paragraph = section.Footers.Primary.AddParagraph();
            paragraph.AddText(string.Format("{0} - {1}", author, DateTime.Now.Year));
            paragraph.Format.Font.Size = 9;
            paragraph.Format.Alignment = ParagraphAlignment.Center;

            section.AddParagraph(" ");
            paragraph = section.AddParagraph();
            paragraph.Format.Font.Bold = true;
            paragraph.AddText("SCHEDULE A");
            paragraph.AddLineBreak();
            paragraph.AddText("PROPERTY");
            paragraph.Format.Alignment = ParagraphAlignment.Center;

            table = section.AddTable();
            table.Borders.Color = new Color(0, 0, 0);
            table.Borders.Width = 0.5;
            table.Style         = "Table";
            column = table.AddColumn("13cm");
            column.Format.Font.Size = 8;
            column = table.AddColumn("4cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column.Format.Font.Size = 8;
            row = table.AddRow();
            row.Cells[0].AddParagraph("Description");
            row.Cells[0].Format.Alignment = ParagraphAlignment.Center;
            row.Cells[0].Format.Font.Bold = true;
            row.Cells[1].AddParagraph("Seller's Reserve");
            row.Cells[1].Format.Font.Bold = true;
            foreach (var item in items)
            {
                row = table.AddRow();
                row.Cells[0].AddParagraph(string.Format("{0}{1}", item.LinkParams.Lot > 0 ? string.Format("Lot {0}. ", item.LinkParams.Lot) : string.Empty, item.LinkParams.Title));
                row.Cells[0].Format.Font.Size = 7;
                row.Cells[1].AddParagraph(item.Reserve.GetCurrency(false));
                row.Cells[1].Format.Font.Size = 7;
            }
            var y = 38 - items.Count;

            for (int i = 0; i < y; i++)
            {
                table.AddRow();
            }

            section.AddParagraph(" ");
            paragraph = section.AddParagraph();
            paragraph.Format.Font.Bold = true;
            paragraph.AddText("Seller agrees with the foregoing, and agrees to keep confidential all of the terms and conditions of this agreement by signing in the space provided below:");
            paragraph.Format.Alignment = ParagraphAlignment.Center;
            paragraph.Format.Font.Size = 7;

            section.AddParagraph(" ");
            section.AddParagraph(" ");

            table  = section.AddTable();
            column = table.AddColumn("3cm");
            column.Format.Alignment = ParagraphAlignment.Right;
            column = table.AddColumn("6cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column = table.AddColumn("6cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            row = table.AddRow();
            row.Cells[0].AddParagraph("Date:");
            row.Cells[0].Format.Font.Size = 6;
            paragraph = row.Cells[1].AddParagraph(date.ToShortDateString());
            paragraph.Format.Font.Size = 6;
            paragraph.AddLineBreak();
            FormattedText formattedText;

            if (string.IsNullOrWhiteSpace(sellerSignaturePath))
            {
                formattedText             = paragraph.AddFormattedText("___________________________");
                formattedText.Superscript = true;
                formattedText.Font.Size   = 10;
            }
            row = table.AddRow();
            row.Cells[0].AddParagraph("Agreed to by:");
            row.Cells[0].Format.Font.Size  = 6;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[1].VerticalAlignment = VerticalAlignment.Bottom;
            if (string.IsNullOrWhiteSpace(sellerSignaturePath))
            {
                paragraph                 = row.Cells[1].AddParagraph();
                formattedText             = paragraph.AddFormattedText("___________________________");
                formattedText.Superscript = true;
            }
            else
            {
                row.Cells[1].AddImage(sellerSignaturePath);
            }
            paragraph                      = row.Cells[1].AddParagraph();
            formattedText                  = paragraph.AddFormattedText("Seller");
            formattedText.Superscript      = true;
            row.Cells[2].VerticalAlignment = VerticalAlignment.Bottom;
            row.Cells[2].AddImage(lelandsSignaturePath);
            paragraph                 = row.Cells[2].AddParagraph();
            formattedText             = paragraph.AddFormattedText("Lelands.com");
            formattedText.Superscript = true;

            section = document.AddSection();

            paragraph = section.AddParagraph("TERMS & CONDITIONS");
            paragraph.Format.Alignment  = ParagraphAlignment.Center;
            paragraph.Format.Font.Bold  = true;
            paragraph.Format.Font.Size  = 10;
            paragraph.Format.SpaceAfter = 15;

            string[] lines = contract.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
            foreach (var line in lines)
            {
                paragraph = section.AddParagraph(line);
                paragraph.Format.Font.Size  = 8;
                paragraph.Format.SpaceAfter = 10;
                //section.AddParagraph(" ");
            }

            // A flag indicating whether to create a Unicode PDF or a WinAnsi PDF file.
            // This setting applies to all fonts used in the PDF document.
            // This setting has no effect on the RTF renderer.
            bool unicode = true;

            // An enum indicating whether to embed fonts or not.
            // This setting applies to all font programs used in the document.
            // This setting has no effect on the RTF renderer.
            // (The term 'font program' is used by Adobe for a file containing a font. Technically a 'font file'
            // is a collection of small programs and each program renders the glyph of a character when executed.
            // Using a font in PDFsharp may lead to the embedding of one or more font programms, because each outline
            // (regular, bold, italic, bold+italic, ...) has its own fontprogram)
            PdfFontEmbedding embedding = PdfFontEmbedding.Always; // Set to PdfFontEmbedding.None or PdfFontEmbedding.Always only

            // ----------------------------------------------------------------------------------------
            // Create a renderer for the MigraDoc document.
            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            // Associate the MigraDoc document with a renderer
            pdfRenderer.Document = document;
            // Layout and render document to PDF
            pdfRenderer.RenderDocument();

            // Save the document...
            pdfRenderer.PdfDocument.Save(filePath);
        }
Exemple #24
0
 /// <summary>
 /// Adds a new image to the footnote.
 /// </summary>
 public void Add(Image image)
 {
     Elements.Add(image);
 }