how to format PDF Invoice ?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 年 前
the default format of PDF invoice gives shipping and billing address in a long format

I want something like this

Billing Address                                                                 Shipping Addres
John Lee                                                                           John Lee
123 street 101 ave                                                           123 street 101 ave
London                                                                              London
UK 10001                                                                          UK 10001



Please direct me to the right direction ?
14 年 前
anyone ?????
14 年 前
1. Open PDFHelper class
2. Find PrintOrderToPDF method
3. Use the following code to render addresses in table (2 column)
int[] addressColumnWidths = new int[1] { 100 };
            int addressCount = 1;
            if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired)
            {
                addressColumnWidths = new int[2] { 50, 50 };
                addressCount = 2;
            }
            Table addressTable = new Table(addressCount, 1);
            addressTable.BorderWidth = 0;
            addressTable.DefaultCell.Border = 0;
            addressTable.AutoFillEmptyCells = true;
            addressTable.Cellpadding = 0;
            addressTable.Width = 100f;
            addressTable.SetWidths(addressColumnWidths);


            //billing info
            Cell billingAddressCell = new Cell();
            billingAddressCell.Add(new Paragraph(" "));
            billingAddressCell.Add(new Paragraph(LocalizationManager.GetLocaleResourceString("PDFInvoice.BillingInformation", LanguageID), fBold));
            if (!String.IsNullOrEmpty(order.BillingCompany))
                billingAddressCell.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Company", LanguageID), order.BillingCompany), f));
            billingAddressCell.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Name", LanguageID), order.BillingFullName), f));            
            billingAddressCell.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Phone", LanguageID), order.BillingPhoneNumber), f));
            if (!String.IsNullOrEmpty(order.BillingFaxNumber))
                billingAddressCell.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Fax", LanguageID), order.BillingFaxNumber), f));
            billingAddressCell.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Address", LanguageID), order.BillingAddress1), f));
            if (!String.IsNullOrEmpty(order.BillingAddress2))
                doc.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Address2", LanguageID), order.BillingAddress2), f));
            billingAddressCell.Add(new Paragraph("   " + String.Format("{0}, {1}", order.BillingCountry, order.BillingStateProvince), f));
            billingAddressCell.Add(new Paragraph("   " + String.Format("{0}, {1}", order.BillingCity, order.BillingZipPostalCode), f));
            billingAddressCell.Add(new Paragraph(" "));
            addressTable.AddCell(billingAddressCell);

            //shipping info
            if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired)
            {
                Cell shippingAddressCell = new Cell();
                shippingAddressCell.Add(new Paragraph(" "));
                shippingAddressCell.Add(new Paragraph(LocalizationManager.GetLocaleResourceString("PDFInvoice.ShippingInformation", LanguageID), fBold));
                if (!String.IsNullOrEmpty(order.ShippingCompany))
                    shippingAddressCell.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Company", LanguageID), order.ShippingCompany), f));            
                shippingAddressCell.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Name", LanguageID), order.ShippingFullName), f));
                shippingAddressCell.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Phone", LanguageID), order.ShippingPhoneNumber), f));
                if (!String.IsNullOrEmpty(order.ShippingFaxNumber))
                    shippingAddressCell.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Fax", LanguageID), order.ShippingFaxNumber), f));
                shippingAddressCell.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Address", LanguageID), order.ShippingAddress1), f));
                if (!String.IsNullOrEmpty(order.ShippingAddress2))
                    doc.Add(new Paragraph("   " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Address2", LanguageID), order.ShippingAddress2), f));
                shippingAddressCell.Add(new Paragraph("   " + String.Format("{0}, {1}", order.ShippingCountry, order.ShippingStateProvince), f));
                shippingAddressCell.Add(new Paragraph("   " + String.Format("{0}, {1}", order.ShippingCity, order.ShippingZipPostalCode), f));
                shippingAddressCell.Add(new Paragraph(" "));
                addressTable.AddCell(shippingAddressCell);
            }
            
            doc.Add(addressTable);
            doc.Add(new Paragraph(" "));
14 年 前
would you please show me how to add logo to the pdf invoice? Thanks
14 年 前
Here is what I use:

      
      Cell rightHeaderCell = new Cell();
      rightHeaderCell.HorizontalAlignment = Element.ALIGN_RIGHT;
      rightHeaderCell.VerticalAlignment = Element.ALIGN_TOP;
      Image logo = Image.GetInstance( new Uri( "http://www.elementalcoffeeroasters.com/images/logo_graphic.gif" ) );
      logo.ScalePercent( 50 );
      rightHeaderCell.Add( logo );
14 年 前
Hi, Just before I try, can I use "~/folder/images/logo_graphic.gif" instead.
I am still run it in local computer.
Thanks,
14 年 前
I dont think so. I think you have to use the full URL to the image. I am pretty sure I tried it and it wouldn't build.
14 年 前
Yes, you are right.  I just try it without local folder.  I get all kinds of errors.
Thanks so much for help me out.  I will try with my local ip.
14 年 前
Hi, I have no luck. I don't know what I am doing wrong or missing.  I used the "http://www...", but when rebuild the project it give me the same list of errors. (62 errors relates to Metadata file 'C:\\......\Nop.BusinessLogic.dll' could not be found.
Should I add it to the bin of Nop.businesslogic?  There is not thing in there before.
Thanks
14 年 前
Rebuild the solution.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.