Esempio n. 1
0
    /// <summary>
    /// Defines page setup, headers, and footers.
    /// </summary>
    static void DefineContentSection(Document document, Project currentProject)
    {
    	try {
    	  Section section = document.AddSection();
	      section.PageSetup.OddAndEvenPagesHeaderFooter = true;
	      section.PageSetup.StartingNumber = 1;
	
	      HeaderFooter header = section.Headers.Primary;
	      header.AddParagraph(currentProject.Name);
	      
	      header = section.Headers.EvenPage;
	      header.AddParagraph(currentProject.Name);
	
	      // Create a paragraph with centered page number. See definition of style "Footer".
	      Paragraph paragraph = new Paragraph();
	      paragraph.AddTab();
	      paragraph.AddPageField();
	
	      // Add paragraph to footer for odd pages.
	      section.Footers.Primary.Add(paragraph);
	      // Add clone of paragraph to footer for odd pages. Cloning is necessary because an object must
	      // not belong to more than one other object. If you forget cloning an exception is thrown.
	      section.Footers.EvenPage.Add(paragraph.Clone());
    	} catch (Exception ex) {
    		throw ex;
    	}
     
    }
Esempio n. 2
0
        /// <summary>
        /// Defines page setup, headers, and footers.
        /// </summary>
        private static void DefineContentSection(Document document, List<QueryData> data )
        {
            Section section = document.AddSection();
            //section.PageSetup.OddAndEvenPagesHeaderFooter = true;
            section.PageSetup.StartingNumber = 1;

            HeaderFooter header = section.Headers.Primary;
            header.AddParagraph(data[0].ProjectName + " - Отчет проверки данных от " + DateTime.Now.ToShortDateString() );
            header.Format.Alignment = ParagraphAlignment.Center;
            // Create a paragraph with centered page number. See definition of style "Footer".
            Paragraph paragraph = new Paragraph();
            paragraph.AddTab();
            paragraph.AddPageField();
            paragraph.AddText(" из ");
            paragraph.AddNumPagesField();
            // Add paragraph to footer for odd pages.
            section.Footers.Primary.Add(paragraph);
            // Add clone of paragraph to footer for odd pages. Cloning is necessary because an object must
            // not belong to more than one other object. If you forget cloning an exception is thrown.
            section.Footers.EvenPage.Add(paragraph.Clone());
        }
Esempio n. 3
0
        /// <summary>
        /// Defines page setup, headers, and footers.
        /// </summary>
        static void DefineContentSection(Document document, ArticlesWithWordMigra article)
        {
            Section section = document.AddSection();
            section.PageSetup.OddAndEvenPagesHeaderFooter = false;
            section.PageSetup.StartingNumber = 1;

            HeaderFooter header = section.Headers.Primary;
            header.AddParagraph(article.EditionName +"\t"+ article.Url);
                    
            // Create a paragraph with centered page number. See definition of style "Footer".
            Paragraph paragraph = new Paragraph();
            paragraph.AddTab();
            paragraph.AddPageField();

            // Add paragraph to footer for odd pages.
            section.Footers.Primary.Add(paragraph);
            
        }
Esempio n. 4
0
        void DefineRevisionHistory(Document document, string fontName, Color fontColor, List<RevisionHistory> listRevisionHistory)
        {
            Section section = document.AddSection();
            section.PageSetup.OddAndEvenPagesHeaderFooter = true;
            section.PageSetup.StartingNumber = 1;

            Paragraph paragraph = new Paragraph();
            paragraph.AddTab();
            paragraph.AddPageField();

            section.Headers.Primary.Add(paragraph);
            section.Headers.EvenPage.Add(paragraph.Clone());

            DocumentFormat.DefineHeading(document, "Revision History", "Heading1", "Revision History");
            DocumentFormat.DefineParagraph(document, "", ParagraphAlignment.Center);

            string[] strArrayHeader = new string[4] { "Version", "Author", "Issue Date", "Changes" };
            string[] strArrayHeaderSize = new string[4] { (PageWidth / 4).ToString() + "cm", (PageWidth / 4).ToString() + "cm", (PageWidth / 4).ToString() + "cm", (PageWidth / 4).ToString() + "cm" };
            Table table = DocumentFormat.CreateSimpleTable(strArrayHeader, strArrayHeaderSize, DataStaging.GetStrMatrixFromListRevisionHistory(listRevisionHistory), FontName, Colors.Black, Colors.LightGray, 12, 0.5, 0.5, true);

            document.LastSection.Add(table);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        private void defineFooter()
        {
            Section section = document.AddSection();
            section.PageSetup.OddAndEvenPagesHeaderFooter = true;
            section.PageSetup.StartingNumber = 1;

            HeaderFooter header = section.Headers.Primary;

            header = section.Headers.EvenPage;

            // Create a paragraph with centered page number. See definition of style "Footer".
            Paragraph paragraph = new Paragraph();
            paragraph.AddTab();
            paragraph.AddPageField();

            // Add paragraph to footer for odd pages.
            section.Footers.Primary.Add(paragraph);
            // Add clone of paragraph to footer for odd pages. Cloning is necessary because an object must
            // not belong to more than one other object. If you forget cloning an exception is thrown.
            section.Footers.EvenPage.Add(paragraph.Clone());
        }
Esempio n. 7
0
 public void VisitTabSymbol()
 {
     _pdfParagraph.AddTab();
 }
Esempio n. 8
0
    public Document CreateDocument()
    {
        Document document = new Document();

        document.Info.Title = "Existing Client Task List";
        document.Info.Author = "Sol-TBCRM";
        document.Info.Subject = "";

        using (SqlConnection oConn = new SqlConnection(Connect.sConnStr))
        {
            oConn.Open();

            // Read the list of new clients
            string strQuery;
            if ((string)Session["LoggedInUserID"] == "7")
                strQuery = "select MarketerUserID, EventAssignedUserID, ClientID, MarketerName, MarketerSurname, users.sName as AssignedName, users.sSurname as AssignedSurname, dtCreated, sMessage, sClientName, sClientNumber, sContactPerson, sTelephone from (select MarketerUserID, EventAssignedUserID, ClientID, users.sName as MarketerName, users.sSurname as MarketerSurname, dtCreated, sMessage, sClientName, sClientNumber, sContactPerson, sTelephone from (select MarketerUserID, EventAssignedUserID, existing_clients.PKiClientID as ClientID, dtCreated, sMessage, existing_clients.sName as sClientName, existing_clients.sClientNumber, existing_clients.sContactPerson, existing_clients.sTelephone from (select marketer_assignment.FKiUserID as MarketerUserID, events.FKiExistingClientID as EventClientID, events.FKiUserAssignedID as EventAssignedUserID, events.dtCreated, events.sMessage  from events inner join marketer_assignment on events.FKiExistingClientID = marketer_assignment.FKiClientID  WHERE events.sStatus = 'Active') MarketerEventJoin inner join existing_clients on MarketerEventJoin.EventClientID = existing_clients.PKiClientID WHERE existing_clients.bExcluded = 0) MarketerEventsClientsJoin inner join users on users.PKiUserId = MarketerUserID) FinalJoin inner join users on PKiUserID = EventAssignedUserID ORDER BY MarketerUserID, ClientID, dtCreated";
            else
                strQuery = "select MarketerUserID, EventAssignedUserID, ClientID, MarketerName, MarketerSurname, users.sName as AssignedName, users.sSurname as AssignedSurname, dtCreated, sMessage, sClientName, sClientNumber, sContactPerson, sTelephone from (select MarketerUserID, EventAssignedUserID, ClientID, users.sName as MarketerName, users.sSurname as MarketerSurname, dtCreated, sMessage, sClientName, sClientNumber, sContactPerson, sTelephone from (select MarketerUserID, EventAssignedUserID, existing_clients.PKiClientID as ClientID, dtCreated, sMessage, existing_clients.sName as sClientName, existing_clients.sClientNumber, existing_clients.sContactPerson, existing_clients.sTelephone from (select marketer_assignment.FKiUserID as MarketerUserID, events.FKiExistingClientID as EventClientID, events.FKiUserAssignedID as EventAssignedUserID, events.dtCreated, events.sMessage  from events inner join marketer_assignment on events.FKiExistingClientID = marketer_assignment.FKiClientID  WHERE events.sStatus = 'Active' AND marketer_assignment.FKiUserID = '" + (string)Session["LoggedInUserID"] + "') MarketerEventJoin inner join existing_clients on MarketerEventJoin.EventClientID = existing_clients.PKiClientID WHERE existing_clients.bExcluded = 0) MarketerEventsClientsJoin inner join users on users.PKiUserId = MarketerUserID) FinalJoin inner join users on PKiUserID = EventAssignedUserID ORDER BY MarketerUserID, ClientID, dtCreated";

            SqlDataReader reader = Connect.getDataCommand(strQuery, oConn).ExecuteReader();

            int lastuserid = -1;
            int lastclientid = -1;
            int numclients = 0;
            int numevents = 0;
            DateTime lastdate = DateTime.MinValue;
            if (!reader.HasRows)
            {
                Section section = document.AddSection();
                section.PageSetup.PageFormat = PageFormat.A4;
                section.AddParagraph("No items for user '" + (string)Session["LoggedInUserID"] + "'");
            }
            while (reader.Read())
            {
                // Start new section
                if ((int)reader["MarketerUserID"] != lastuserid)
                {
                   /* if (lastuserid != -1)
                        document.LastSection.AddPageBreak();*/
                    numclients = 0;
                    lastuserid = (int)reader["MarketerUserID"];
                    // Create a paragraph with centered page number. See definition of style "Footer".
                    Paragraph paragraph = new Paragraph();
                    paragraph.AddTab();
                    paragraph.AddPageField();
                    // Add a section to the document
                    Section section = document.AddSection();
                    section.PageSetup.PageFormat = PageFormat.A4;
                    section.PageSetup.StartingNumber = 1;

                    // Add paragraph to footer for odd pages.
                    section.Footers.Primary.Add(paragraph);

                    HeaderFooter header = section.Headers.Primary;
                    header.AddParagraph(DateTime.Now.ToString() + "\t\t" + (string)reader["MarketerName"] + " " + (string)reader["MarketerSurname"] + " Task List");

                    paragraph = section.AddParagraph();
                    paragraph.Format.Font.Name = "Arial";
                    paragraph.Format.Font.Size = Unit.FromPoint(18);
                    paragraph.Format.SpaceBefore = Unit.FromCentimeter(2);
                    paragraph.Format.SpaceAfter = Unit.FromCentimeter(2);
                    paragraph.Format.Alignment = ParagraphAlignment.Center;
                    paragraph.AddText((string)reader["MarketerName"] + " " + (string)reader["MarketerSurname"] + " Task List\n");
                    Table table = section.AddTable();
                    table.Format.Alignment = ParagraphAlignment.Left;
                    Column column = table.AddColumn(Unit.FromCentimeter(1));
                    table.AddColumn(Unit.FromCentimeter(2));
                    table.AddColumn(Unit.FromCentimeter(5));
                    table.AddColumn(Unit.FromCentimeter(5));
                    table.AddColumn(Unit.FromCentimeter(3));
                    Row row = table.AddRow();
                    row.Format.Font.Italic = true;
                    row.Format.SpaceAfter = Unit.FromMillimeter(5);
                    Cell cell = row.Cells[0];
                    cell.AddParagraph("#");
                    cell = row.Cells[1];
                    cell.AddParagraph("Code");
                    cell = row.Cells[2];
                    cell.AddParagraph("Client");
                    cell = row.Cells[3];
                    cell.AddParagraph("Contact");
                    cell = row.Cells[4];
                    cell.AddParagraph("Telephone");

                    numclients++;
                    numevents = 1;
                    lastclientid = (int)reader["ClientID"];
                    AddClient(document, reader, numclients);
                    lastdate = (DateTime)reader["dtCreated"];
                    AddDate(document, reader);
                    AddEvent(document, reader, numevents);
                }
                else // Continue in section
                {
                    // New client
                    if ((int)reader["ClientID"] != lastclientid)
                    {
                        lastclientid = (int)reader["ClientID"];
                        lastdate = (DateTime)reader["dtCreated"];
                        numclients++;
                        numevents = 1;
                        AddClient(document, reader, numclients);
                        AddDate(document, reader);
                        AddEvent(document, reader, numevents);
                    }
                    else // Continue with same client
                    {
                        DateTime newdate = (DateTime)reader["dtCreated"];
                        if (newdate.Year != lastdate.Year && newdate.Month != lastdate.Month && newdate.Day != lastdate.Day) // New date
                        {
                            AddDate(document, reader);
                            numevents = 1;
                            AddEvent(document, reader, numevents);
                        }
                        else // Continue with same date
                        {
                            numevents++;
                            AddEvent(document, reader, numevents);
                        }
                    }
                }
            }

            reader.Close();
            oConn.Close();
        }
        return document;
    }
Esempio n. 9
0
        public void CreateCharacterCertificatePDF(string[] CertificateData, string admNo, int admYear)
        {
            if (CertificateData.Length != 5)
            {
                return;
            }
            else
            {
                // Generate nmhs-nexap directory in my document folder
                string containerfolder  = this.GenerateDocumentBaseDirectory();
                MigraModel.Document doc = new MigraModel.Document();
                MigraModel.Section  sec = doc.AddSection();
                sec.PageSetup           = doc.DefaultPageSetup.Clone();
                sec.PageSetup.TopMargin = ".7cm";

                MigraDoc.DocumentObjectModel.Shapes.TextFrame tframe = sec.AddTextFrame();
                tframe.AddImage("nmhs-logo.jpg");
                tframe.Left               = "-.5cm";
                tframe.Top                = "0.7cm";
                tframe.RelativeVertical   = MigraModel.Shapes.RelativeVertical.Page;
                tframe.RelativeHorizontal = MigraModel.Shapes.RelativeHorizontal.Margin;

                MigraModel.Paragraph paraSchoolName = sec.AddParagraph();
                paraSchoolName.Format.Font.Name  = "Times New Roman";
                paraSchoolName.Format.Alignment  = MigraModel.ParagraphAlignment.Center;
                paraSchoolName.Format.Font.Size  = 25;
                paraSchoolName.Format.Font.Color = MigraDoc.DocumentObjectModel.Colors.DarkBlue;
                string schoolName = "NAIMOUZA HIGH SCHOOL";
                paraSchoolName.AddFormattedText(schoolName, MigraModel.TextFormat.Bold);

                MigraModel.Paragraph paraSchoolAddress = sec.AddParagraph();
                paraSchoolAddress.Format.Font.Size = 14;
                paraSchoolAddress.Format.Alignment = MigraModel.ParagraphAlignment.Center;
                string addrs = "Vill. & P.O. Sujapur, Dist. Malda, 732206";
                paraSchoolAddress.AddText(addrs);

                MigraModel.Paragraph paraSchoolMeta = sec.AddParagraph();
                paraSchoolMeta.Format.Font.Size = 10;
                paraSchoolMeta.Format.Alignment = MigraModel.ParagraphAlignment.Center;
                string meta = "INDEX NO. - R1-110, CONTACT NO. - 03512-246525";
                paraSchoolMeta.AddFormattedText(meta, MigraModel.TextFormat.NotBold);

                MigraModel.Paragraph paraAdmissionMeta = sec.AddParagraph();
                paraAdmissionMeta.Format.Font.Size = 10;
                paraAdmissionMeta.Format.Alignment = MigraModel.ParagraphAlignment.Right;
                string admYr = (admYear != 0) ? admYear.ToString() : "0000";
                string ameta = "Admission Sl. " + admNo + " of " + admYr;
                paraAdmissionMeta.AddFormattedText(ameta, MigraModel.TextFormat.Bold);

                MigraModel.Paragraph paraCertificateType = sec.AddParagraph();
                paraCertificateType.Format.Font.Size = 18;
                paraCertificateType.Format.Alignment = MigraModel.ParagraphAlignment.Center;
                paraCertificateType.AddLineBreak();
                string ctype = "CHARACTER CERTIFICATE";
                paraCertificateType.AddFormattedText(ctype, MigraModel.TextFormat.NotBold);

                MigraModel.Paragraph para_a = sec.AddParagraph();
                para_a.Format.Font.Name  = "Lucida Handwriting";
                para_a.Format.Font.Size  = 16;
                para_a.Format.Font.Color = MigraModel.Colors.DarkBlue;
                para_a.Format.Alignment  = MigraModel.ParagraphAlignment.Justify;
                para_a.AddLineBreak();
                para_a.AddLineBreak();
                para_a.AddLineBreak();
                para_a.AddLineBreak();
                para_a.AddTab();

                string para_aText, para_aTextb, paraTextc, paraTextd, stdName;
                para_aText  = CertificateData[0].Trim();
                para_aTextb = CertificateData[1].Trim();
                paraTextc   = CertificateData[2].Trim();
                paraTextd   = CertificateData[3].Trim();
                stdName     = CertificateData[4].Trim();

                para_a.AddText(para_aText);

                MigraModel.Paragraph para_b = sec.AddParagraph();
                para_b.Format.Font.Name  = "Lucida Handwriting";
                para_b.Format.Font.Size  = 16;
                para_b.Format.Font.Color = MigraModel.Colors.DarkBlue;
                para_b.Format.Alignment  = MigraModel.ParagraphAlignment.Justify;
                para_b.AddLineBreak();
                para_b.AddTab();
                para_b.AddText(para_aTextb);

                MigraModel.Paragraph para_c = sec.AddParagraph();
                para_c.Format.Font.Name  = "Lucida Handwriting";
                para_c.Format.Font.Size  = 16;
                para_c.Format.Font.Color = MigraModel.Colors.DarkBlue;
                para_c.Format.Alignment  = MigraModel.ParagraphAlignment.Justify;
                para_c.AddLineBreak();
                para_c.AddTab();
                para_c.AddText(paraTextc);

                MigraModel.Paragraph para_d = sec.AddParagraph();
                para_d.Format.Font.Name  = "Lucida Handwriting";
                para_d.Format.Font.Size  = 16;
                para_d.Format.Font.Color = MigraModel.Colors.DarkBlue;
                para_d.Format.Alignment  = MigraModel.ParagraphAlignment.Justify;
                para_d.AddLineBreak();
                para_d.AddTab();
                para_d.AddText(paraTextd);


                MigraDoc.DocumentObjectModel.Shapes.TextFrame tframeHMaster = sec.AddTextFrame();
                MigraModel.Paragraph paraHMaster = tframeHMaster.AddParagraph();
                paraHMaster.Format.Font.Size = "14";
                paraHMaster.Format.Alignment = MigraModel.ParagraphAlignment.Center;
                string txt1 = "Headmaster";
                string txt2 = "Naimuza High School";
                string txt3 = "Sujapur, Malda";
                paraHMaster.AddText(txt1);
                paraHMaster.AddLineBreak();
                paraHMaster.AddText(txt2);
                paraHMaster.AddLineBreak();
                paraHMaster.AddText(txt3);
                tframeHMaster.Width              = "6cm";
                tframeHMaster.Left               = "10cm";
                tframeHMaster.Top                = "19cm";
                tframeHMaster.RelativeVertical   = MigraModel.Shapes.RelativeVertical.Page;
                tframeHMaster.RelativeHorizontal = MigraModel.Shapes.RelativeHorizontal.Margin;

                MigraDoc.Rendering.PdfDocumentRenderer docRend = new MigraDoc.Rendering.PdfDocumentRenderer(false);
                docRend.Document = doc;
                try
                {
                    docRend.RenderDocument();
                }
                catch (Exception e)
                {
                    System.Windows.MessageBox.Show(e.Message);
                    return;
                }
                string fname      = "CHR_" + stdName + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".pdf";
                string pathString = Path.Combine(containerfolder, fname);
                docRend.PdfDocument.Save(pathString);

                System.Diagnostics.ProcessStartInfo processInfo = new System.Diagnostics.ProcessStartInfo();
                processInfo.FileName = pathString;
                System.Diagnostics.Process.Start(processInfo);
            }
        }
Esempio n. 10
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);
        }