how to format PDF Invoice ?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 лет назад
Yes, it has.  and it has a long list of using
here is its list:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NopSolutions.NopCommerce.BusinessLogic.Orders;
using iTextSharp.text.pdf;
using System.IO;
using iTextSharp.text;
using NopSolutions.NopCommerce.BusinessLogic.Products;
using NopSolutions.NopCommerce.BusinessLogic.Measures;
using NopSolutions.NopCommerce.BusinessLogic.Directory;
using NopSolutions.NopCommerce.BusinessLogic.Tax;
using NopSolutions.NopCommerce.BusinessLogic.Payment;
using NopSolutions.NopCommerce.BusinessLogic.Shipping;
using NopSolutions.NopCommerce.BusinessLogic.Localization;
14 лет назад
Can you paste the exact Logo code (those 3 lines) you have?
14 лет назад
Holliday, I don't guess it.  I just use the auto fill with Uri popup and the curly line is gone away.  There picture is there now.
With your programming, may I know why is that? it does not like my typing.
14 лет назад
Since it works, then I moved the code back to exactly where I put before and build solution with out any errors. The picture is there now.

I really don't get it.

doc.Open();
Image gif = Image.getInstance(new Uri("http://www.something.com/images/logo.gif"));
doc.Add(gif);
14 лет назад
Thank you so much for your help and patience.
Tony
14 лет назад
Hi, I thought I am ok, but I come to other thing with Company Name.
I follow andrei's code and I can not get the copany name.  all I have is "pdfinvoice.company".  it looks like the code display itself in the form and does not pul the company information.
Would you plz help me with it? Thanks
14 лет назад
double check your localization strings to make sure that string is there and has a value.
14 лет назад
Holliday, a part of pdfhelp has these code:

            Cell billingAddressCell = new Cell();
            billingAddressCell.Add(new Paragraph(" "));
            billingAddressCell.Add(new Paragraph(LocalizationManager.GetLocaleResourceString("PDFInvoice.BillingInformation", LanguageID)));
            if (!String.IsNullOrEmpty(order.BillingCompany))
                billingAddressCell.Add(new Paragraph("    " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Company", LanguageID), order.BillingCompany)));
            billingAddressCell.Add(new Paragraph("    " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Name", LanguageID), order.BillingFullName)));

I also look into localization folder and can not figure out what will be related to.

Tony
14 лет назад
It looks like many one interested in this topic.  Hope you have a little bit of your time to help with this.
14 лет назад
anthny wrote:
It looks like many one interested in this topic.  Hope you have a little bit of your time to help with this.


Hi,

First point regarding images. You don't need to use the absolute image url to add an image you can use:


doc.Add(Image.GetInstance(Server.MapPath("~/content/images/logo.jpg")));


Secondly, I have an improved templating solution that I hope to add to nopCommerce in the next month or so. This will give you much more control over both email message templates and PDFs.

But to help you out in the meantime, iTextSharp has a HTMLWorker object that does an okay job of converting a html document into a PDF so things like tables are quite easy to do.

The code below (written for another application) passes a string result (contains the html to convert) to the HTMLWorker.Parse method. This creates a number of elements to be added to the PDF document.


string result = _templateService.RenderTemplate("TestEmail.htm", objs);

            StyleSheet stylesheet = new StyleSheet();
            stylesheet.LoadTagStyle("body", "color", "darkblue");
            stylesheet.LoadTagStyle("body", "size", "10px");

            var html = HTMLWorker.ParseToList(new StringReader(result), stylesheet);

using (MemoryStream ms = new MemoryStream())
            {
                var writer = PdfWriter.GetInstance(doc, ms);
                doc.Open();
                doc.Add(Image.GetInstance(Server.MapPath("~/content/images/logo.jpg")));
                doc.Add(new Paragraph());
                foreach (var e in html) {
                    doc.Add((IElement)e);
                }
                doc.Close();



Hope this helps some people in the meantime.

Ben
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.