Non-English customer data in PDF forms of invoice & packaging slip

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Reinstall nopCommerce (you updated InstallationService, but your instance is already installed) or manually update 'PdfSettings.FontFileName' setting in admin area (configuration > settings > all settings)
12 years ago
Hi Andrei,

I followed this post, I had the same problem with the creation of a pdf file.
after I started I new project - 2.3 - It worked, BUT - I'm using HEBREW, and all the letters are like English - left to right,
how can I make the Hebrew go right to left?

thanks

Ariel
12 years ago
RTL characters are supported, but RTL text direction for PDF files is not supported yet
12 years ago
a.m. wrote:
Reinstall nopCommerce (you updated InstallationService, but your instance is already installed) or manually update 'PdfSettings.FontFileName' setting in admin area (configuration > settings > all settings)


bingo...It works perfect. Thanks
12 years ago
organic wrote:
The used font doesn't support all characters. If your font is not supported, then you can use any other Unicode font. Just copy it into \App_Data\Pdf directory.

P.S. I know what ArialUni.ttf font (provided with MS Office) support almost languages, but we can't distribute it with nopCommerce because it's not allowed (not open source).

Hi, I copied ARIALUNI.TTF to the folder. It didn't work.

And I changed pdf file to ARIALUNI.TTF at line 4455 in installationService.cs file.
EngineContext.Current.Resolve<IConfigurationProvider<PdfSettings>>()
                .SaveSettings(new PdfSettings()
                {
                    Enabled = true,
                    LetterPageSizeEnabled = false,
                    RenderOrderNotes = true,
                    FontFileName = "ARIALUNI.TTF", /////////////////////FontFileName = "FreeSerif.ttf",
                });

Still doesn't work. please let me if I mssed anything?


I think that "SaveSettings" method  of  "installationService.cs" runs during installation.  If you want to change a default font after installation,  you need to change "GetFont" method in PdfService.cs like as follows.


        protected virtual Font GetFont()
        {
            //nopCommerce supports unicode characters
            //nopCommerce uses Free Serif font by default (~/App_Data/Pdf/FreeSerif.ttf file)
            //It was downloaded from http://savannah.gnu.org/projects/freefont
            //string fontPath = Path.Combine(HostingEnvironment.MapPath("~/App_Data/Pdf/"), _pdfSettings.FontFileName);
            string fontPath = Path.Combine(HostingEnvironment.MapPath("~/App_Data/Pdf/"), "ArialUni.ttf");
            var baseFont = BaseFont.CreateFont(fontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            var font = new Font(baseFont, 10, Font.NORMAL);
            return font;
        }
12 years ago
is there a fix also for version 1.9 ?
10 years ago
infact after I searched for couple of hours for a solution  for RTL and I thought it is impossible I found out that all is needed to specify the direction of the Cells and tables and am still working on paragraph so here is the solution for RTL languages

first of all I copied a line from the head.cshtml which is

var supportRtl = EngineContext.Current.Resolve<IWorkContext>().WorkingLanguage.Rtl;
if (supportRtl)
{}
else
{}

and copied it to method PrintOrdersToPdf(Stream stream, IList<Order> orders, int languageId = 0) which is located in libraries/nop.services/common/PDFservice.cs

and I did the following

1- modify the code to become

var supportRtl = _workContext.WorkingLanguage.Rtl;

2- after each definition of tablecell or table I add the lines
  var tablename= new PdfPTable();
   if (supportRtl)
            tablename.RunDirection = PdfWriter.RUN_DIRECTION_RTL;


cell

var cellname = new PdfPCell();
               if (supportRtl)
                        cellname .RunDirection = PdfWriter.RUN_DIRECTION_RTL;

and that did the trick but you need to figure out how to apply it to the paragraph since am still working on it

a.m. wrote:
RTL characters are supported, but RTL text direction for PDF files is not supported yet
9 years ago
Done. Please see changeset 9930d403a162
3 years ago
hi,
I'm using V4.3 and I encountered the same problem with Chinese character not shown in pdf invoice.
Is there any solution for this bug with detail steps?
Many thanks.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.