Esempio n. 1
0
        public void TestGetHyperlinkTextElements()
        {
            string    linkName      = "hyperlinkName";
            string    linkText      = "link text";
            string    linkFormatted = "link formatted text";
            Paragraph paragraph     = document.LastSection.AddParagraph();
            Hyperlink link          = paragraph.AddHyperlink(linkName);

            link.AddText(linkText);
            link.AddFormattedText(linkFormatted);
            List <string> textElements = paragraph.Elements.GetTextElements().ToList();

            Assert.AreEqual(2, textElements.Count);
            Assert.AreEqual(linkText, textElements[0]);
            Assert.AreEqual(linkFormatted, textElements[1]);
        }
            /// <summary>
            /// Create Footer for document
            /// </summary>
            /// <param name="section"></param>
            /// <remarks></remarks>
            private void CreateFooter(Section section)
            {
                //Dim info As ApplicationServices.AssemblyInfo
                //info = New ApplicationServices.AssemblyInfo("RescueTekniq.Doc")

                var with_1 = section.Footers.Primary.AddParagraph();
                var with_2 = with_1.Format;

                with_2.Font.Size = 5;
                with_2.Alignment = ParagraphAlignment.Right;
                with_1.AddDateField();
                with_1.AddLineBreak();
                //.AddText(info.Version.ToString)

                var with_3 = section.Footers.Primary.AddParagraph();
                var with_4 = with_3.Format;

                with_4.Font.Size = 9;
                with_4.Alignment = ParagraphAlignment.Center;
                with_3.AddText("- ");
                with_3.AddPageField();
                with_3.AddText(" / ");
                with_3.AddNumPagesField();
                with_3.AddText(" -");

                var with_5 = section.Footers.Primary.AddParagraph();
                var with_6 = with_5.Format;

                with_6.Font.Size = 7;
                with_5.AddText(Company.name);
                with_5.AddLineBreak();
                with_5.AddText(Company.adresse);
                with_5.AddLineBreak();
                with_5.AddText(Company.zipcode);
                with_5.AddText(" ");
                with_5.AddText(Company.city);
                if (this._AED.Virksomhed.LandekodeID != 45)
                {
                    with_5.AddText(", ");
                    with_5.AddText(Company.country);
                }
                with_5.AddLineBreak();
                if (this._AED.Virksomhed.LandekodeID != 45)
                {
                    with_5.AddText("Phone ");
                    with_5.AddText(Company.int_phone);
                }
                else
                {
                    with_5.AddText("Telefon ");
                    with_5.AddText(Company.phone);
                }
                with_5.AddLineBreak();

                with_5.AddText("E-mail: ");
                Hyperlink _email = with_5.AddHyperlink(string.Format("mailto:{0}", Company.email), HyperlinkType.Web);

                _email.AddFormattedText(Company.email);
                with_5.AddLineBreak();

                with_5.AddText("Internet: ");
                Hyperlink link = with_5.AddHyperlink(string.Format("http://{0}", Company.link), HyperlinkType.Web);

                link.AddFormattedText(Company.link);
            }
        /// <summary>
        /// Creates the static parts of the invoice.
        /// </summary>
        private void CreatePage()
        {
            // Each MigraDoc document needs at least one section.
            Section section = this.document.AddSection();
            var     with_2  = section.PageSetup;

            //.HeaderDistance = "1cm"
            with_2.TopMargin = "4,5cm";

            with_2.BottomMargin   = "3,0cm";
            with_2.FooterDistance = "0,3cm";
            // Create footer


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

            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;

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

            // Create the text frame for the address
            //section.Headers.Primary.AddParagraph()
            this.deleveryFrame       = section.Headers.Primary.AddTextFrame(); //AddParagraph() 'section.AddTextFrame()
            this.deleveryFrame.Top   = "2.0cm";
            this.deleveryFrame.Left  = "7.00cm";                               //ShapePosition.Left
            this.deleveryFrame.Width = "5.0cm";
            //.Height = "3.0cm"
            this.deleveryFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.deleveryFrame.RelativeVertical   = RelativeVertical.Page;


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

            with_7.SpaceBefore         = "1cm";
            with_7.Font.Size           = 7;
            with_7.Borders.Color       = RescueTekniq.Doc.IncassoForm_Dk.TableBorder;
            with_7.Borders.Width       = 0.25;
            with_7.Borders.Left.Width  = 0.5;
            with_7.Borders.Right.Width = 0.5;
            with_7.Alignment           = ParagraphAlignment.Center;
            paragraph.AddText(Config.Company.name);
            paragraph.AddText(" · ");

            paragraph.AddText(Config.Company.adresse);

            paragraph.AddText(" · ");
            paragraph.AddText(Config.Company.zipcode);
            paragraph.AddText(" ");
            paragraph.AddText(Config.Company.city);
            if (this.Incasso.Virksomhed.LandekodeID != 45)
            {
                paragraph.AddText(" · ");
                paragraph.AddText(Config.Company.country);
            }
            paragraph.AddText(" · ");
            paragraph.AddText("CVR.nr. ");
            paragraph.AddText(Config.Company.vatno);
            paragraph.AddText(" · ");
            if (this.Incasso.Virksomhed.LandekodeID != 45)
            {
                paragraph.AddText("Pho. ");
                paragraph.AddText(Config.Company.int_phone);
            }
            else
            {
                paragraph.AddText("Tlf. ");
                paragraph.AddText(Config.Company.phone);
            }
            paragraph.AddText(" · ");
            Hyperlink link = paragraph.AddHyperlink("http://" + Config.Company.link, HyperlinkType.Web);

            link.AddFormattedText(Config.Company.link);

            var with_8 = section.Footers.Primary.AddParagraph();
            var with_9 = with_8.Format;

            with_9.Font.Size = 4;
            with_9.Alignment = ParagraphAlignment.Center;
            with_8.AddLineBreak();
            with_8.AddLineBreak();

            with_8.AddText(string.Format("- {0}Incasso varsel nr. {1}", EANtitle, Incasso.ID));
            if (IsCopy)
            {
                with_8.AddText(" kopi");
            }

            with_8.AddText(" - side ");
            with_8.AddPageField();
            with_8.AddText(" af ");
            with_8.AddNumPagesField();
            with_8.AddText(" - ");

            // Create the text frame for the address
            this.headerFrame                    = section.AddTextFrame();
            this.headerFrame.Height             = "2.0cm";
            this.headerFrame.Width              = "5.5cm";
            this.headerFrame.Left               = ShapePosition.Right;
            this.headerFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.headerFrame.Top                = "4.5cm";
            this.headerFrame.RelativeVertical   = RelativeVertical.Page;
            // Add the print date field
            paragraph = this.headerFrame.AddParagraph();
            string Cvrnr = Config.Company.vatno;

            paragraph.Style = "Reference";
            //.Format.Alignment = ParagraphAlignment.Right

            //Select Case Invoice.Status
            //    Case Invoice_StatusEnum.IncassoNotis
            //        '.AddFormattedText("Incasso varsel", TextFormat.Bold)
            //    Case Invoice_StatusEnum.FirstReminder
            //        .AddFormattedText(String.Format("1. Rykker på faktura nr.{0}", Invoice.ID), TextFormat.Bold)
            //    Case Else
            //        .AddFormattedText(String.Format("{0}Faktura nr. {1}", EANtitle, Invoice.ID), TextFormat.Bold)
            //        If IsCopy Then
            //            .AddFormattedText(" - kopi", TextFormat.Bold)
            //        End If
            //End Select
            //.AddLineBreak()

            paragraph.AddText("Dato: ");
            paragraph.AddDateField("yyyy-MM-dd");
            paragraph.AddLineBreak();

            paragraph.AddText("Sagsnr.: ");
            paragraph.AddFormattedText(string.Format("{0}", Incasso.ID), TextFormat.Bold);
            paragraph.AddLineBreak();

            paragraph.AddText("Kreditor: ");
            paragraph.AddFormattedText(Config.Company.name, TextFormat.Bold);
            paragraph.AddLineBreak();

            paragraph.AddLineBreak();



            // Add the print date field
            paragraph = section.AddParagraph();
            paragraph.Format.SpaceBefore = "3cm";
            paragraph.Style = "Reference";

            paragraph.AddFormattedText(string.Format("Incasso varsel - Vedr. faktura nr. {0}", Incasso.Invoice.ID), TextFormat.Bold);
            paragraph.AddLineBreak();

            // Add the print date field
            paragraph       = section.AddParagraph();
            paragraph.Style = "Reference";
            paragraph.AddText("Vi skal hermed rykke Dem for betaling af Deres gæld, som nu er opgjort til:");
            //Select Case Invoice.Status
            //    Case Invoice_StatusEnum.IncassoNotis
            //        .AddText(String.Format("{0} har bedt os om at rykke Dem for betaling af Deres gæld, som nu er opgjort til:", Config.Company.name))
            //    Case Invoice_StatusEnum.FirstReminder
            //        .AddText(String.Format("Hermed skal vi bringe vort tilgodehavende i henhold til ovennævnte faktura nr. {0} i erindring – da vi ikke kan se at denne er betalt", Invoice.ID))
            //        ' – og vi skal herved erindre om indbetaling af nedennævnte beløb.", Invoice.ID))
            //        .AddLineBreak()
            //        .AddText("Såfremt beløbet er indbetalt inden modtagelse af denne skrivelse – bedes De bortse fra denne.")
            //        .AddLineBreak()
            //    Case Else
            //        .AddText("I henhold til aftale fremsendes hermed faktura på:")
            //End Select


            // Create the item table
            this.table       = section.AddTable();
            this.table.Style = "Table";
            //.Borders.Color = TableBorder
            this.table.Borders.Width       = 0; //0.25 '0.25
            this.table.Borders.Left.Width  = 0; //0.5
            this.table.Borders.Right.Width = 0; //0.5
            this.table.Rows.LeftIndent     = 0;
            this.table.Format.Font.Size    = "8pt";
            this.table.Format.Alignment    = ParagraphAlignment.Center;

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

            var with_15 = this.table.AddColumn("1cm");

            with_15.Format.Alignment = ParagraphAlignment.Left;
            var with_16 = this.table.AddColumn("12,5cm");

            with_16.Format.Alignment = ParagraphAlignment.Left;

            var with_17 = this.table.AddColumn("2,5cm");

            with_17.Format.Alignment = ParagraphAlignment.Right;


            //' Create the header of the table
            //Dim row As Row
            //row = table.AddRow()
            //With row
            //    .HeadingFormat = True
            //    .Format.Alignment = ParagraphAlignment.Center
            //    .Format.Font.Bold = True
            //    .Shading.Color = TableBlue

            //    .Cells(0).AddParagraph("Vare nr")
            //    .Cells(0).Format.Alignment = ParagraphAlignment.Left

            //    .Cells(1).AddParagraph("i alt")
            //    .Cells(1).Format.Alignment = ParagraphAlignment.Right

            //End With

            //Me.table.SetEdge(0, 0, 7, 1, Edge.Box, BorderStyle.[Single], 0.75, Color.Empty)
        }
        /// <summary>
        /// Creates the static parts of the invoice.
        /// </summary>
        private void OrderForm_CreatePage()
        {
            // Each MigraDoc document needs at least one section.
            Section section = this.document.AddSection();
            var     with_2  = section.PageSetup;

            //.HeaderDistance = "1cm"
            with_2.TopMargin = "4,5cm";

            with_2.BottomMargin   = "3,0cm";
            with_2.FooterDistance = "0,3cm";
            // Create footer


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

            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;

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

            // Create the text frame for the address
            //section.Headers.Primary.AddParagraph()
            this.deleveryFrame       = section.Headers.Primary.AddTextFrame(); //AddParagraph() 'section.AddTextFrame()
            this.deleveryFrame.Top   = "2.0cm";
            this.deleveryFrame.Left  = "7.00cm";                               //ShapePosition.Left
            this.deleveryFrame.Width = "5.0cm";
            //.Height = "3.0cm"
            this.deleveryFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.deleveryFrame.RelativeVertical   = RelativeVertical.Page;


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

            with_7.SpaceBefore         = "1cm";
            with_7.Font.Size           = 7;
            with_7.Borders.Color       = RescueTekniq.Doc.OrderForm_Dk.TableBorder;
            with_7.Borders.Width       = 0.25;
            with_7.Borders.Left.Width  = 0.5;
            with_7.Borders.Right.Width = 0.5;
            with_7.Alignment           = ParagraphAlignment.Center;
            paragraph.AddText(Company.name); //("Heart2Start ApS")
            paragraph.AddText(" · ");

            paragraph.AddText(Company.adresse); //("Gefionsvej 8")

            paragraph.AddText(" · ");
            paragraph.AddText(Company.zipcode); //("3400")
            paragraph.AddText(" ");
            paragraph.AddText(Company.city);    //("Hillerød")
            if (this.Invoice.Virksomhed.LandekodeID != 45)
            {
                paragraph.AddText(" · ");
                paragraph.AddText(Company.country); //("Denmark")
            }
            paragraph.AddText(" · ");
            paragraph.AddText("CVR.nr. ");
            paragraph.AddText(Company.vatno); //("32446329")
            paragraph.AddText(" · ");
            if (this.Invoice.Virksomhed.LandekodeID != 45)
            {
                paragraph.AddText("Pho. ");
                paragraph.AddText(Company.int_phone); //("+45 48212879")
            }
            else
            {
                paragraph.AddText("Tlf. ");
                paragraph.AddText(Company.phone); //("48212879")
            }
            paragraph.AddText(" · ");
            //.AddText("www.RescueTekniq.dk")
            Hyperlink link = paragraph.AddHyperlink(string.Format("http://{0}", Company.link), HyperlinkType.Web);

            link.AddFormattedText(Company.link); //("www.RescueTekniq.dk")
            //.AddHyperlink("www.RescueTekniq.dk", HyperlinkType.Web)

            var with_8 = section.Footers.Primary.AddParagraph();
            var with_9 = with_8.Format;

            with_9.Font.Size = 4;
            with_9.Alignment = ParagraphAlignment.Center;
            with_8.AddLineBreak();
            with_8.AddLineBreak();
            with_8.AddText("- " + EANtitle + "Faktura nr. " + Invoice.ID.ToString());
            if (IsCopy)
            {
                with_8.AddText(" kopi");
            }
            with_8.AddText(" - side ");
            with_8.AddPageField();
            with_8.AddText(" af ");
            with_8.AddNumPagesField();
            with_8.AddText(" - ");

            // Create the text frame for the address
            this.headerFrame                    = section.AddTextFrame();
            this.headerFrame.Height             = "2.0cm";
            this.headerFrame.Width              = "5.5cm";
            this.headerFrame.Left               = ShapePosition.Right;
            this.headerFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.headerFrame.Top                = "4.5cm";
            this.headerFrame.RelativeVertical   = RelativeVertical.Page;
            // Add the print date field
            paragraph = this.headerFrame.AddParagraph();
            string Cvrnr = Company.vatno; //ConfigurationManager.AppSettings("company.vatno")

            // <add key="company.vatno" value="32446329" />

            paragraph.Style = "Reference";
            //.Format.Alignment = ParagraphAlignment.Right
            paragraph.AddFormattedText(EANtitle + "Følgebrev nr. " + Invoice.ID.ToString(), TextFormat.Bold);
            paragraph.AddLineBreak();

            paragraph.AddText(Company.city); //("Hillerød, ")
            paragraph.AddLineBreak();
            paragraph.AddText("dato: ");
            paragraph.AddText(Invoice.InvoiceDate.ToString("dd-MM-yyyy"));
            //.AddDateField("dd. MMM yyyy")
            paragraph.AddLineBreak();

            paragraph.AddText("CVR: ");
            paragraph.AddFormattedText(Cvrnr, TextFormat.Bold);
            paragraph.AddLineBreak();

            paragraph.AddText(this.Invoice.RettetAf.ToUpper());
            paragraph.AddText("/");
            if (this.Invoice.ResponsibleName.Trim() != "")
            {
                paragraph.AddText(this.Invoice.ResponsibleName.ToUpper());
            }
            paragraph.AddLineBreak();

            paragraph.AddLineBreak();

            paragraph.AddText("Side ");
            paragraph.AddPageField();
            paragraph.AddText(" af ");
            paragraph.AddNumPagesField();


            // Add the print date field
            paragraph = section.AddParagraph();
            paragraph.Format.SpaceBefore = "3cm";
            paragraph.Style = "Reference";
            paragraph.AddFormattedText(EANtitle + "Følgebrev", TextFormat.Bold);
            paragraph.AddLineBreak();

            // Add the print date field
            paragraph       = section.AddParagraph();
            paragraph.Style = "Reference";
            paragraph.AddText("I henhold til aftale fremsendes hermed:");

            // Create the item table
            this.table                     = section.AddTable();
            this.table.Style               = "Table";
            this.table.Borders.Color       = RescueTekniq.Doc.OrderForm_Dk.TableBorder;
            this.table.Borders.Width       = 0.25; //0.25
            this.table.Borders.Left.Width  = 0.5;
            this.table.Borders.Right.Width = 0.5;
            this.table.Rows.LeftIndent     = 0;
            this.table.Format.Font.Size    = "8pt";

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

            column = this.table.AddColumn("2,25cm"); // - Item no
            column.Format.Alignment = ParagraphAlignment.Right;

            column = this.table.AddColumn(); //("6,50cm") ' - Item Name / Serial No
            column.Format.Alignment = ParagraphAlignment.Right;

            column = this.table.AddColumn("1,00cm"); // - Quantity
            column.Format.Alignment = ParagraphAlignment.Center;

            //column = Me.table.AddColumn("1,50cm") ' - Item Price
            //column.Format.Alignment = ParagraphAlignment.Right

            //column = Me.table.AddColumn("1,25cm") ' - Discount
            //column.Format.Alignment = ParagraphAlignment.Right

            //column = Me.table.AddColumn("1,50cm") ' - Sales price
            //column.Format.Alignment = ParagraphAlignment.Right

            //column = Me.table.AddColumn("2,00cm") ' - Line total
            //column.Format.Alignment = ParagraphAlignment.Right
            //'   Sum CM must be = 16 cm | 1+7,5+2+1+2+2,5
            //'

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

            row = table.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = RescueTekniq.Doc.OrderForm_Dk.TableBlue;

            row.Cells[0].AddParagraph("Vare nr");
            row.Cells[0].Format.Alignment = ParagraphAlignment.Left;

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

            row.Cells[2].AddParagraph("Antal");
            //.Cells(2).Format.Font.Bold = False
            row.Cells[2].Format.Alignment = ParagraphAlignment.Left;
            //.Cells(2).VerticalAlignment = VerticalAlignment.Bottom

            //.Cells(3).AddParagraph("Stk. pris ") 'DKK
            //.Cells(3).Format.Alignment = ParagraphAlignment.Left

            //.Cells(4).AddParagraph("Rabat") ' (%)Ambassadør - Reduktion
            //.Cells(4).Format.Alignment = ParagraphAlignment.Left

            //.Cells(5).AddParagraph("á pris")
            //.Cells(5).Format.Alignment = ParagraphAlignment.Left

            //.Cells(6).AddParagraph("i alt DKK")
            //.Cells(6).Format.Alignment = ParagraphAlignment.Right
            //'.Cells(6).VerticalAlignment = VerticalAlignment.Bottom
            //'.Cells(6).MergeDown = 1


            this.table.SetEdge(0, 0, 3, 1, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
        }
Esempio n. 5
0
        public static void WriteFormattedParagraphFromContent(ref Paragraph p, string content)
        {
            //replace the vars
            string moddedcontent = content;


            moddedcontent = content.Replace("%refference%", "b.bookingReference");

            string[] content_array = moddedcontent.Split('|');

            foreach (string s in content_array)
            {
                if (s != string.Empty)
                {
                    if (s.First().ToString() == "l")
                    {
                        p.AddLineBreak();

                        string s1 = s.Remove(0, 1);

                        if (s1.First().ToString() == "b")
                        {
                            p.AddFormattedText(s1.Remove(0, 1), TextFormat.Bold);
                        }
                        else if (s1.First().ToString() == "t")
                        {
                            p.AddFormattedText(s1.Remove(0, 1), StyleNames.Heading9);
                        }
                        else if (s1.First().ToString() == "r")
                        {
                            p.AddFormattedText(s1.Remove(0, 1), StyleNames.Heading6);
                        }
                        else if (s1.First().ToString() == "c")
                        {
                            p.AddFormattedText(s1.Remove(0, 1), TextFormat.Bold);
                        }

                        else if (s1.First().ToString() == "u")
                        {
                            p.AddFormattedText(s1.Remove(0, 1), StyleNames.Heading7);
                        }
                        else if (s1.First().ToString() == "o" && s1[1].ToString() == " ")
                        {
                            p.AddFormattedText(s1.Remove(0, 1), StyleNames.Heading4);
                        }
                        else if (s1.First().ToString() == "z")
                        {
                            p.AddFormattedText(s1.Remove(0, 1), StyleNames.Heading8);
                        }
                        else if (s1.First().ToString() == "")
                        {
                            // p.AddFormattedText(s1.Remove(0, 1), StyleNames.Heading4);
                        }

                        else if (s1.First().ToString() == "a")
                        {
                            p.AddFormattedText("  " + s1.Remove(0, 1), TextFormat.Bold);
                        }
                        else if (s1.First().ToString() == "h")
                        {
                            string hlinktext = s1.Remove(0, 1).Split('=').Last().Trim();

                            if (hlinktext.Length > 4)
                            {
                                if (hlinktext.Substring(0, 4).ToLower() != "http")
                                {
                                    hlinktext = "http://" + hlinktext;
                                }
                            }

                            Hyperlink hlink = p.AddHyperlink(hlinktext, HyperlinkType.Url);
                            hlink.Font.Color      = new Color(24, 106, 207);
                            hlink.Font.Underline += 1;

                            hlink.AddFormattedText(s1.Remove(0, 1).Split('=').First());
                        }
                        else if (s1.First().ToString() == "e")
                        {
                            string hlinktext = "mailto:" + s1.Remove(0, 1);

                            Hyperlink hlink = p.AddHyperlink(hlinktext, HyperlinkType.Url);
                            hlink.Font.Color      = new Color(24, 106, 207);
                            hlink.Font.Underline += 1;
                            hlink.AddFormattedText(s1.Remove(0, 1).ToUpper(), TextFormat.Bold);
                        }
                        else if (s1.First().ToString() == "s")
                        {
                            p.AddSpace(1);
                        }
                        else
                        {
                            p.AddText(s1);
                        }
                    }

                    else
                    {
                        if (s.First().ToString() == "b")
                        {
                            p.AddFormattedText(s.Remove(0, 1), TextFormat.Bold);
                        }
                        else if (s.First().ToString() == "t")
                        {
                            p.AddFormattedText(s.Remove(0, 1), StyleNames.Heading9);
                        }
                        else if (s.First().ToString() == "c")
                        {
                            p.AddFormattedText(s.Remove(0, 1), TextFormat.Bold);
                        }
                        else if (s.First().ToString() == "r")
                        {
                            p.AddFormattedText(s.Remove(0, 1), StyleNames.Heading6);
                        }
                        else if (s.First().ToString() == "u")
                        {
                            p.AddFormattedText(s.Remove(0, 1), StyleNames.Heading7);
                        }
                        else if (s.First().ToString() == "o" && s[1].ToString() == " ")
                        {
                            p.AddFormattedText(s.Remove(0, 1), StyleNames.Heading4);
                        }

                        else if (s.First().ToString() == "a")
                        {
                            p.AddFormattedText("  " + s.Remove(0, 1), TextFormat.Bold);
                        }
                        else if (s.First().ToString() == "h")
                        {
                            string hlinktext = s.Remove(0, 1).Split('=').Last().Trim();
                            if (hlinktext.Length > 4)
                            {
                                if (hlinktext.Substring(0, 4).ToLower() != "http")
                                {
                                    hlinktext = "http://" + hlinktext;
                                }
                            }

                            Hyperlink hlink = p.AddHyperlink(hlinktext, HyperlinkType.Url);
                            hlink.Font.Color      = new Color(24, 106, 207);
                            hlink.Font.Underline += 1;

                            hlink.AddFormattedText(s.Remove(0, 1).Split('=').First());
                        }
                        else if (s.First().ToString() == "e")
                        {
                            string hlinktext = "mailto:" + s.Remove(0, 1);

                            Hyperlink hlink = p.AddHyperlink(hlinktext, HyperlinkType.Url);
                            hlink.Font.Color      = new Color(24, 106, 207);
                            hlink.Font.Underline += 1;

                            hlink.AddFormattedText(s.Remove(0, 1).ToUpper(), TextFormat.Bold);
                        }
                        else if (s.First().ToString() == "s")
                        {
                            p.AddSpace(1);
                        }
                        else
                        {
                            p.AddText(s);
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Creates the static parts of the invoice.
        /// </summary>
        private void CreatePage()
        {
            // Each MigraDoc document needs at least one section.
            Section section = this.document.AddSection();
            var     with_2  = section.PageSetup;

            //.HeaderDistance = "1cm"
            with_2.TopMargin = "4,5cm";

            with_2.BottomMargin   = "3,0cm";
            with_2.FooterDistance = "0,3cm";
            // Create footer


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

            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;

            // Create the text frame for the address
            //section.Headers.Primary.AddParagraph()
            this.addressFrame = section.Headers.Primary.AddTextFrame(); //AddParagraph() 'section.AddTextFrame()
            //.Height = "3.0cm"
            this.addressFrame.Width = "8.0cm";
            this.addressFrame.Left  = ShapePosition.Left;
            this.addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.addressFrame.Top = "2.0cm";
            this.addressFrame.RelativeVertical = RelativeVertical.Page;


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

            with_6.SpaceBefore         = "1cm";
            with_6.Font.Size           = 7;
            with_6.Borders.Color       = RescueTekniq.Doc.TilbudFolgemail_Dk.TableBorder;
            with_6.Borders.Width       = 0.25;
            with_6.Borders.Left.Width  = 0.5;
            with_6.Borders.Right.Width = 0.5;
            with_6.Alignment           = ParagraphAlignment.Center;
            paragraph.AddText(Company.name);
            paragraph.AddText(" · ");
            paragraph.AddText(Company.adresse);
            paragraph.AddText(" · ");
            paragraph.AddText(Company.zipcode);
            paragraph.AddText(" ");
            paragraph.AddText(Company.city);
            if (this.tilbud.Virksomhed.LandekodeID != 45)
            {
                paragraph.AddText(" · ");
                paragraph.AddText(Company.country);
            }
            paragraph.AddText(" · ");
            paragraph.AddText("CVR.nr. ");
            paragraph.AddText(Company.vatno);
            paragraph.AddText(" · ");
            if (this.tilbud.Virksomhed.LandekodeID != 45)
            {
                paragraph.AddText("Pho. ");
                paragraph.AddText(Company.int_phone);
            }
            else
            {
                paragraph.AddText("Tlf. ");
                paragraph.AddText(Company.phone);
            }
            paragraph.AddText(" · ");
            Hyperlink link = paragraph.AddHyperlink(string.Format("http://{0}", Company.link), HyperlinkType.Web);

            link.AddFormattedText(Company.link);


            var with_7 = section.Footers.Primary.AddParagraph();
            var with_8 = with_7.Format;

            with_8.Font.Size = 4;
            with_8.Alignment = ParagraphAlignment.Center;
            with_7.AddLineBreak();
            with_7.AddLineBreak();
            with_7.AddText("- TILBUD nr. " + tilbud.ID.ToString());
            with_7.AddText(" - side ");
            with_7.AddPageField();
            with_7.AddText(" af ");
            with_7.AddNumPagesField();
            with_7.AddText(" - ");

            // Create the text frame for the address
            this.headerFrame                    = section.AddTextFrame();
            this.headerFrame.Height             = "2.0cm";
            this.headerFrame.Width              = "4.0cm";
            this.headerFrame.Left               = ShapePosition.Right;
            this.headerFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.headerFrame.Top                = "4.5cm";
            this.headerFrame.RelativeVertical   = RelativeVertical.Page;
            // Add the print date field
            paragraph       = this.headerFrame.AddParagraph();
            paragraph.Style = "Reference";
            //.Format.Alignment = ParagraphAlignment.Right
            paragraph.AddFormattedText("TILBUD nr. " + tilbud.ID.ToString(), TextFormat.Bold);
            paragraph.AddLineBreak();
            paragraph.AddText(Company.city); //("Hillerød, ")
            paragraph.AddText(", ");
            paragraph.AddDateField("dd.MM.yyyy");
            paragraph.AddLineBreak();
            paragraph.AddText(System.Convert.ToString("/" + System.Convert.ToString(this.tilbud.Ansvarlig != "" ? this.tilbud.Ansvarlig : "LFU")));

            paragraph.AddLineBreak();
            paragraph.AddLineBreak();
            paragraph.AddText("Side ");
            paragraph.AddPageField();
            paragraph.AddText(" af ");
            paragraph.AddNumPagesField();


            //' Put sender in address frame
            //paragraph = Me.addressFrame.AddParagraph()
            //With paragraph
            //    .AddText("Heart2Start Aps · Gefionsvej 8 · 3400 Hillerød")
            //    .Format.Font.Name = "Times New Roman"
            //    .Format.Font.Size = 7
            //    .Format.SpaceAfter = 3
            //End With

            // Add the print date field
            //paragraph = section.AddParagraph()
            //With paragraph
            //    .Format.SpaceBefore = "5cm"
            //    .Style = "Reference"
            //    .AddFormattedText("TILBUD nr. " & tilbud.ID.ToString, TextFormat.Bold)
            //    .AddTab()
            //    .AddText("Hillerød, ")
            //    .AddDateField("dd.MM.yyyy")
            //    .Format.Font.Color = RGB(255, 0, 0)
            //End With

            // Add the print date field
            paragraph = section.AddParagraph();
            paragraph.Format.SpaceBefore = "3cm";
            paragraph.Style = "Reference";
            paragraph.AddFormattedText("Fremsendelse af tilbud", TextFormat.Bold);
            paragraph.AddLineBreak();
            // Add the print date field
            paragraph       = section.AddParagraph();
            paragraph.Style = "Reference";
            paragraph.AddText("I henhold til aftale fremsendes hermed tilbud på:");

            // Create the item table
            this.table                     = section.AddTable();
            this.table.Style               = "Table";
            this.table.Borders.Color       = RescueTekniq.Doc.TilbudFolgemail_Dk.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;

            column = this.table.AddColumn("1cm"); //1cm - Antal
            column.Format.Alignment = ParagraphAlignment.Center;

            column = this.table.AddColumn("7,75cm"); //3cm - Beskrivelse
            column.Format.Alignment = ParagraphAlignment.Right;

            column = this.table.AddColumn("1,75cm"); //3cm - Stk. pris DKK
            column.Format.Alignment = ParagraphAlignment.Right;

            column = this.table.AddColumn("1,75cm"); //3cm - Reduktion
            column.Format.Alignment = ParagraphAlignment.Right;

            column = this.table.AddColumn("1,75cm"); //3cm - á pris
            column.Format.Alignment = ParagraphAlignment.Right;

            column = this.table.AddColumn("2cm"); //3cm - i alt
            column.Format.Alignment = ParagraphAlignment.Right;
            //   1+(5*3) = 16 cm | 1+7,5+2+1+2+2,5

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

            //row = table.AddRow()
            //With row
            //    .HeadingFormat = True
            //    .Format.Alignment = ParagraphAlignment.Center
            //    .Format.Font.Bold = True
            //    .Shading.Color = TableBlue
            //    .Cells(0).AddParagraph("Antal")
            //    .Cells(0).Format.Font.Bold = False
            //    .Cells(0).Format.Alignment = ParagraphAlignment.Left
            //    .Cells(0).VerticalAlignment = VerticalAlignment.Bottom
            //    .Cells(0).MergeDown = 1

            //    .Cells(1).AddParagraph("Beskrivelse")
            //    .Cells(1).Format.Alignment = ParagraphAlignment.Left
            //    .Cells(1).MergeRight = 3

            //    .Cells(5).AddParagraph("i alt")
            //    .Cells(5).Format.Alignment = ParagraphAlignment.Right 'Left
            //    .Cells(5).VerticalAlignment = VerticalAlignment.Bottom
            //    .Cells(5).MergeDown = 1
            //End With

            row = table.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = RescueTekniq.Doc.TilbudFolgemail_Dk.TableBlue;

            row.Cells[0].AddParagraph("Antal");
            row.Cells[0].Format.Font.Bold  = false;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Bottom;
            //.Cells(0).MergeDown = 1

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

            row.Cells[2].AddParagraph("Stk. pris "); //DKK
            row.Cells[2].Format.Alignment = ParagraphAlignment.Left;

            row.Cells[3].AddParagraph("Reduktion"); // (%)Ambassadør - Reduktion
            row.Cells[3].Format.Alignment = ParagraphAlignment.Left;

            row.Cells[4].AddParagraph("á pris");
            row.Cells[4].Format.Alignment = ParagraphAlignment.Left;

            row.Cells[5].AddParagraph("i alt");
            row.Cells[5].Format.Alignment  = ParagraphAlignment.Right; //Left
            row.Cells[5].VerticalAlignment = VerticalAlignment.Bottom;
            //.Cells(5).MergeDown = 1


            this.table.SetEdge(0, 0, 6, 1, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
        }
        private void AddBesked()
        {
            Section LastSec = this.document.LastSection;

            //With LastSec.AddParagraph()
            //    .Format.SpaceBefore = "5mm"
            //    '.Format.Font.Size = 7
            //    Dim RegNo As String = Config.Bank.RegNo
            //    Dim AccountNo As String = Config.Bank.AccountNo
            //    Dim BankName As String = Config.Bank.Name
            //    Dim BankAdr As String = Config.Bank.Address
            //    Dim BankSwift As String = Config.Bank.SWIFT
            //    Dim BankIBAN As String = Config.Bank.IBAN
            //    '.AddText("Betalingsbetingelser : ")
            //    '.AddFormattedText(Me.PurchaseOrder.PaymentTerms, TextFormat.Bold)
            //    '.AddLineBreak()
            //End With

            //With LastSec.AddParagraph
            //    .Format.SpaceBefore = "5mm"
            //    .AddText("Please send infomation about the expected delivery time.")
            //    .AddLineBreak()
            //End With

            var with_1 = LastSec.AddParagraph();

            with_1.Format.SpaceBefore = "5mm";
            with_1.AddText("Please send invoice to ");
            Hyperlink link = with_1.AddHyperlink(string.Format("{0}", Config.PurchaseOrder.email), HyperlinkType.Web);

            link.AddFormattedText(Config.PurchaseOrder.email);
            with_1.AddText(string.Format(", attention: {0}.", Config.PurchaseOrder.name));
            with_1.AddLineBreak();

            Font FontTal = new Font();

            FontTal.Color = new Color((byte)255, (byte)0, (byte)0);
            FontTal.Bold  = true;
            var with_3 = LastSec.AddParagraph();

            with_3.Format.SpaceBefore = "5mm";
            //.Format.Font.Size = 7
            with_3.Format.Alignment = ParagraphAlignment.Center;
            with_3.AddText("Regards");
            with_3.AddLineBreak();
            with_3.AddText(Company.name);
            with_3.AddLineBreak();
            //With LastSec.AddParagraph
            //    .Format.SpaceBefore = "0,5cm"
            //    '.Format.Font.Size = 7
            //    .Format.Alignment = ParagraphAlignment.Center

            //    ' Put a signatur image
            //    If SignaturImage <> "" AndAlso SignaturImage <> "signatur.gif" Then
            //        With .AddImage(SignaturImage)
            //            .LockAspectRatio = True
            //            .Width = "3,05cm"
            //            .WrapFormat.Style = WrapStyle.None
            //        End With
            //    End If
            //    .AddLineBreak()
            //    .AddText(Signatur)
            //    .AddLineBreak()
            //End With
        }
        /// <summary>
        /// Creates the static parts of the invoice.
        /// </summary>
        private void CreatePage()
        {
            // Each MigraDoc document needs at least one section.
            Section section = this.document.AddSection();
            var     with_2  = section.PageSetup;

            //.HeaderDistance = "1cm"
            with_2.TopMargin      = "4,0cm";
            with_2.BottomMargin   = "3,0cm";
            with_2.FooterDistance = "0,3cm";
            with_2.Orientation    = Orientation.Landscape;


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

            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;

            // Create the text frame for the vendor name
            this.vendorFrame       = section.Headers.Primary.AddTextFrame();
            this.vendorFrame.Top   = "2.0cm";
            this.vendorFrame.Left  = ShapePosition.Left;
            this.vendorFrame.Width = "7.0cm";
            this.vendorFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.vendorFrame.RelativeVertical   = RelativeVertical.Page;

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

            // Create the text frame for the SHIP TO
            this.deleveryFrame       = section.Headers.Primary.AddTextFrame();
            this.deleveryFrame.Top   = "3.0cm";
            this.deleveryFrame.Left  = "8.00cm"; //ShapePosition.Left
            this.deleveryFrame.Width = "6.0cm";
            //.Height = "3.0cm"
            this.deleveryFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.deleveryFrame.RelativeVertical   = RelativeVertical.Page;

            // Create the text frame for the header info
            this.headerFrame       = section.Headers.Primary.AddTextFrame(); // section.AddTextFrame()
            this.headerFrame.Top   = "2,5cm";
            this.headerFrame.Left  = "16.0cm";                               //ShapePosition.Right
            this.headerFrame.Width = "8.0cm";
            //.Height = "2.0cm"
            this.headerFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.headerFrame.RelativeVertical   = RelativeVertical.Page;

            // Create footer
            var with_8 = section.Footers.Primary.AddParagraph();
            var with_9 = with_8.Format;

            with_9.SpaceBefore         = "1cm";
            with_9.Font.Size           = 7;
            with_9.Borders.Color       = RescueTekniq.Doc.PurchaseOrderForm_Dk.TableBorder;
            with_9.Borders.Width       = 0.25;
            with_9.Borders.Left.Width  = 0.5;
            with_9.Borders.Right.Width = 0.5;
            with_9.Alignment           = ParagraphAlignment.Center;
            with_8.AddText(Company.name);
            with_8.AddText(" · ");
            with_8.AddText(Company.adresse);
            with_8.AddText(" · ");
            with_8.AddText(Company.zipcode);
            with_8.AddText(" ");
            with_8.AddText(Company.city);
            if (this.PurchaseOrder.Supplier.LandekodeID != 45)
            {
                with_8.AddText(" · ");
                with_8.AddText(Company.country);
            }
            with_8.AddText(" · ");
            with_8.AddText("CVR.nr. ");
            with_8.AddText(Company.vatno);
            with_8.AddText(" · ");
            if (this.PurchaseOrder.Supplier.LandekodeID != 45)
            {
                with_8.AddText("Pho. ");
                with_8.AddText(Company.int_phone);
            }
            else
            {
                with_8.AddText("Tlf. ");
                with_8.AddText(Company.phone);
            }
            with_8.AddText(" · ");
            Hyperlink link = with_8.AddHyperlink(string.Format("http://{0}", Company.link), HyperlinkType.Web);

            link.AddFormattedText(Company.link);

            var with_10 = section.Footers.Primary.AddParagraph();
            var with_11 = with_10.Format;

            with_11.Font.Size = 4;
            with_11.Alignment = ParagraphAlignment.Center;
            with_10.AddLineBreak();
            with_10.AddLineBreak();
            with_10.AddText(string.Format("- PurchaseOrder no. {0} - page ", PurchaseOrder.ID.ToString()));
            with_10.AddPageField();
            with_10.AddText(" of ");
            with_10.AddNumPagesField();
            with_10.AddText(" - ");

            var with_12 = section.AddParagraph();

            with_12.Format.SpaceBefore = "3cm";
            with_12.Style = "Reference";
            //.AddFormattedText("PurchaseOrder", TextFormat.Bold)
            with_12.AddFormattedText(string.Format("PurchaseOrder no. {0}", PurchaseOrder.ID.ToString()), TextFormat.Bold);
            with_12.AddLineBreak();

            var with_13 = section.AddParagraph();

            with_13.Style = "Reference";
            with_13.AddText("We hereby submit the purchase order for the following products:");

            // Create the item table
            this.table                     = section.AddTable();
            this.table.Style               = "Table";
            this.table.Borders.Color       = RescueTekniq.Doc.PurchaseOrderForm_Dk.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;
            this.table.Format.Font.Size    = "10pt";

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

            //cell 0
            column = this.table.AddColumn("1,00cm"); // - Line Item (Line no)
            column.Format.Alignment = ParagraphAlignment.Right;

            //cell 1
            column = this.table.AddColumn("12,0cm"); // - Item Name / description
            column.Format.Alignment = ParagraphAlignment.Left;

            //cell 2
            column = this.table.AddColumn("3,50cm"); // - Item no / P/N
            column.Format.Alignment = ParagraphAlignment.Right;

            //cell 3
            column = this.table.AddColumn("1,50cm"); // - Quantity
            column.Format.Alignment = ParagraphAlignment.Center;

            //cell 4
            column = this.table.AddColumn("2,50cm"); // - Item Price / Unit Price (CURR)
            column.Format.Alignment = ParagraphAlignment.Right;

            //cell 5
            column = this.table.AddColumn("2,50cm"); // - Line total
            column.Format.Alignment = ParagraphAlignment.Right;
            //
            //   Sum CM must be = 16 cm | 1+6,5+2,5+1+2,5+2,5
            //

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

            row = table.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = RescueTekniq.Doc.PurchaseOrderForm_Dk.TableBlue;

            row.Cells[0].AddParagraph("Line item"); //0
            row.Cells[0].Format.Alignment = ParagraphAlignment.Center;

            row.Cells[1].AddParagraph("Description"); //1
            row.Cells[1].Format.Alignment = ParagraphAlignment.Center;

            row.Cells[2].AddParagraph("P/N"); //2
            row.Cells[2].Format.Alignment = ParagraphAlignment.Center;

            row.Cells[3].AddParagraph("Qty."); //3
            row.Cells[3].Format.Alignment = ParagraphAlignment.Center;

            row.Cells[4].AddParagraph(string.Format("Unit price ({0})", PurchaseOrder.CurrencyCode)); //4
            row.Cells[4].Format.Alignment = ParagraphAlignment.Center;

            row.Cells[5].AddParagraph("Extension"); //5
            row.Cells[5].Format.Alignment = ParagraphAlignment.Center;


            this.table.SetEdge(0, 0, 6, 1, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
        }