Showing Shipping Method in Order PDF

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 13 ans
I am trying to add shipping method to the order PDF. The label is showign but not the value. I am on v1.4 right now. I will not be able to upgrade to newer version for several weeks and need this to work now as we are having to hand right it in. Here is what I tried:

            //shipping info
            if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired)
            {
                doc.Add(new Paragraph(" "));
                doc.Add(new Paragraph(LocalizationManager.GetLocaleResourceString("PDFInvoice.ShippingInformation", LanguageID)));
                doc.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Shipping", LanguageID), order.ShippingMethod)));
                doc.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Name", LanguageID), order.ShippingFullName)));
                doc.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Phone", LanguageID), order.ShippingPhoneNumber)));
                if (!String.IsNullOrEmpty(order.ShippingFaxNumber))
                    doc.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Fax", LanguageID), order.ShippingFaxNumber)));
                doc.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Address", LanguageID), order.ShippingAddress1)));
                if (!String.IsNullOrEmpty(order.ShippingAddress2))
                    doc.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Address2", LanguageID), order.ShippingAddress2)));
                doc.Add(new Paragraph("   " + String.Format("{0}, {1}", order.ShippingCountry, order.ShippingStateProvince)));
                doc.Add(new Paragraph("   " + String.Format("{0}, {1}", order.ShippingCity, order.ShippingZipPostalCode)));
                doc.Add(new Paragraph(" "));
            }


The shippign method is below the shipping information label. I have confirmed that the value is there when watching the code behind but when the pdf renders and you open it only the shipping methos label shows.

Any ideas?
Il y a 13 ans
vishrb wrote:
I am trying to add shipping method to the order PDF. The label is showign but not the value. I am on v1.4 right now. I will not be able to upgrade to newer version for several weeks and need this to work now as we are having to hand right it in. Here is what I tried:

            //shipping info
            if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired)
            {
                doc.Add(new Paragraph(" "));
                doc.Add(new Paragraph(LocalizationManager.GetLocaleResourceString("PDFInvoice.ShippingInformation", LanguageID)));
                doc.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Shipping", LanguageID), order.ShippingMethod)));
                doc.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Name", LanguageID), order.ShippingFullName)));
                doc.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Phone", LanguageID), order.ShippingPhoneNumber)));
                if (!String.IsNullOrEmpty(order.ShippingFaxNumber))
                    doc.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Fax", LanguageID), order.ShippingFaxNumber)));
                doc.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Address", LanguageID), order.ShippingAddress1)));
                if (!String.IsNullOrEmpty(order.ShippingAddress2))
                    doc.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Address2", LanguageID), order.ShippingAddress2)));
                doc.Add(new Paragraph("   " + String.Format("{0}, {1}", order.ShippingCountry, order.ShippingStateProvince)));
                doc.Add(new Paragraph("   " + String.Format("{0}, {1}", order.ShippingCity, order.ShippingZipPostalCode)));
                doc.Add(new Paragraph(" "));
            }


The shippign method is below the shipping information label. I have confirmed that the value is there when watching the code behind but when the pdf renders and you open it only the shipping methos label shows.

Any ideas?


The localized string "PDFInvoice.Shipping" does not contain a format item ({0}) so the shipping method can not be inserted into the string. You need to change String.Format to String.Concat (changes underlined):
doc.Add(new Paragraph("   " + String.Concat(LocalizationManager.GetLocaleResourceString("PDFInvoice.Shipping", LanguageID), " ", order.ShippingMethod)));

.
Il y a 13 ans
That did it. Interestign as I just used the code already there abd tried to copy it. Bu tit must be magical as it worked but mine did not. :). Anyway I used Concat and that worked great. Thanks.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.