Exemplo n.º 1
0
 private void ConfigureImage(MigraDoc.DocumentObjectModel.Shapes.Image image)
 {
     image.Height             = _document.DefaultPageSetup.PageHeight;
     image.RelativeVertical   = RelativeVertical.Page;
     image.RelativeHorizontal = RelativeHorizontal.Page;
     image.Width = _document.DefaultPageSetup.PageWidth;
 }
Exemplo n.º 2
0
        private void SetInfo(Order order, ref Section section)
        {
            TextFrame frame1 = section.AddTextFrame();

            frame1.RelativeVertical = RelativeVertical.Page;
            frame1.Left             = ShapePosition.Right;
            frame1.Top   = new Unit(1.85, UnitType.Centimeter);
            frame1.Width = new Unit(10, UnitType.Centimeter);
            Paragraph p = frame1.AddParagraph();

            p.Format.Font.Size = 16;
            p.Format.Alignment = ParagraphAlignment.Right;
            p.AddFormattedText("Order #" + order.Id, TextFormat.Bold);

            frame1 = section.AddTextFrame();
            TextFrame frame2 = section.AddTextFrame();

            if (!String.IsNullOrWhiteSpace(_ecommerceSettings.ReportLogoImage) &&
                !_ecommerceSettings.ReportLogoImage.Contains("http"))
            {
                string logoUrl = _getLogoUrl.Get();
                if (!String.IsNullOrWhiteSpace(logoUrl))
                {
                    MigraDoc.DocumentObjectModel.Shapes.Image logo = section.AddImage(logoUrl);
                    logo.RelativeVertical = RelativeVertical.Page;
                    logo.Left             = ShapePosition.Left;
                    logo.Top         = new Unit(1.85, UnitType.Centimeter);
                    logo.Height      = new Unit(1.5, UnitType.Centimeter);
                    frame1.MarginTop = new Unit(0.5, UnitType.Centimeter);
                    frame2.MarginTop = new Unit(0.5, UnitType.Centimeter);
                }
            }

            frame1.RelativeVertical = RelativeVertical.Page;
            frame1.Left             = ShapePosition.Left;
            frame1.Top   = new Unit(3.5, UnitType.Centimeter);
            frame1.Width = new Unit(10, UnitType.Centimeter);

            frame2.RelativeVertical = RelativeVertical.Page;
            frame2.Left             = ShapePosition.Right;
            frame2.Top   = new Unit(3.5, UnitType.Centimeter);
            frame2.Width = new Unit(8, UnitType.Centimeter);

            //BILLING AND SHIPPING
            p = frame1.AddParagraph();
            p.AddFormattedText("Bill to:", TextFormat.Bold);
            p = frame2.AddParagraph();
            p.AddFormattedText("Ship to:", TextFormat.Bold);
            p = frame1.AddParagraph();
            p.AddText(order.BillingAddress.Name);
            if (!string.IsNullOrEmpty(order.BillingAddress.Company))
            {
                p = frame1.AddParagraph();
                p.AddText(order.BillingAddress.Company);
            }

            if (order.ShippingAddress != null)
            {
                p = frame2.AddParagraph();
                p.AddText(order.ShippingAddress.Name);

                if (!string.IsNullOrEmpty(order.ShippingAddress.Company))
                {
                    p = frame2.AddParagraph();
                    p.AddText(order.ShippingAddress.Company);
                }
            }

            if (!string.IsNullOrWhiteSpace(order.BillingAddress?.PhoneNumber))
            {
                p = frame1.AddParagraph();
                p.AddText(order.BillingAddress.PhoneNumber);
            }

            if (!string.IsNullOrWhiteSpace(order.ShippingAddress?.PhoneNumber))
            {
                p = frame2.AddParagraph();
                p.AddText(order.ShippingAddress.PhoneNumber);
            }

            p = frame1.AddParagraph();
            p.AddText(order.BillingAddress.Address1);

            if (order.ShippingAddress != null)
            {
                if (!string.IsNullOrWhiteSpace(order.ShippingAddress.Address1))
                {
                    p = frame2.AddParagraph();
                    p.AddText(order.ShippingAddress.Address1);
                }
            }

            if (!string.IsNullOrWhiteSpace(order.BillingAddress.Address2))
            {
                p = frame1.AddParagraph();
                p.AddText(order.BillingAddress.Address2);
            }

            if (order.ShippingAddress != null)
            {
                if (!string.IsNullOrWhiteSpace(order.ShippingAddress.Address2))
                {
                    p = frame2.AddParagraph();
                    p.AddText(order.ShippingAddress.Address2);
                }
            }

            if (!string.IsNullOrWhiteSpace(order.BillingAddress.City))
            {
                p = frame1.AddParagraph();
                p.AddText(order.BillingAddress.City);
            }

            if (order.ShippingAddress != null)
            {
                if (!string.IsNullOrWhiteSpace(order.ShippingAddress.City))
                {
                    p = frame2.AddParagraph();
                    p.AddText(order.ShippingAddress.City);
                }
            }

            if (!string.IsNullOrWhiteSpace(order.BillingAddress.StateProvince))
            {
                p = frame1.AddParagraph();
                p.AddText(order.BillingAddress.StateProvince);
            }

            if (order.ShippingAddress != null)
            {
                if (!string.IsNullOrWhiteSpace(order.ShippingAddress.StateProvince))
                {
                    p = frame2.AddParagraph();
                    p.AddText(order.ShippingAddress.StateProvince);
                }
            }

            string billingCountryName = order.BillingAddress.GetCountryName();

            if (!string.IsNullOrWhiteSpace(billingCountryName))
            {
                p = frame1.AddParagraph();
                p.AddText(billingCountryName);
            }

            if (order.ShippingAddress != null)
            {
                string shippingCountryName = order.ShippingAddress.GetCountryName();
                if (!string.IsNullOrWhiteSpace(shippingCountryName))
                {
                    p = frame2.AddParagraph();
                    p.AddText(shippingCountryName);
                }
            }

            if (!string.IsNullOrWhiteSpace(order.BillingAddress.PostalCode))
            {
                p = frame1.AddParagraph();
                p.AddText(order.BillingAddress.PostalCode);
            }

            if (order.ShippingAddress != null)
            {
                if (!string.IsNullOrWhiteSpace(order.ShippingAddress.PostalCode))
                {
                    p = frame2.AddParagraph();
                    p.AddText(order.ShippingAddress.PostalCode);
                }
            }

            frame1.AddParagraph("").AddLineBreak();
            frame2.AddParagraph("").AddLineBreak();

            //PAYMENT AND SHIPPING METHODS
            p = frame1.AddParagraph();
            p.AddText(string.Format("Payment method: {0}", order.PaymentMethod.BreakUpString()));
            p = frame2.AddParagraph();
            p.AddText(string.Format("Shipping method: {0}", order.ShippingMethodName));
        }