9 Replies Latest reply on May 22, 2008 6:54 AM by PHRED-SE

    <cfdocument> not showing Chinese character

    PHRED-SE Level 1
      We have a system that uses a mixture of English and Simplified Chinese on almost every page. After properly installing the Simplified Chinese fonts (gb2312) on all of the users PC’s via the Regional and Language setting, the pages display both languages properly.

      We have just started using the <cfdocument> to create PDF documents. We were eager to convert to <cfdocument> in order to be able to use CSS and to be able to display the Chinese characters in the PDF document as they are displayed in the HTML. We tried it first on a CF MX 7 test bed. Once we created the cffont.properties.cn in the cf_root/Lib directory, it worked like a champ.

      In order get this feature into production, we moved the .cfm files and the cffont.properties files from out CF 7 test bed to our CF8 development system. No matter what we do, all we see in the PDF file where the Chinese characters should be are “?”.

      We can’t find any information on anything else that we need to do to make the Chinese characters appear besides creating the cffont.properties files in the cf_root/Lib directory as we did in CF 7. Using the CF Administrator’s Font Manager, I can see that the required Simplified Chinese fonts (NSimSun, SimSun & Simhei) are installed on the server. The bare bones code seems simple enough:
      <cfdocument format=“pdf” fontembed=”selective”>
      Page text…
      </cfdocument.

      If you have done this, or know what we need to do to port form CF7 to CF8, I would appreciate your sharing.

      Thank you in advance for your help.

      :-}
      Len
        • 1. Re: &lt;cfdocument&gt; not showing Chinese character
          Level 7
          PHRED-SE wrote:
          > We have a system that uses a mixture of English and Simplified Chinese on
          > almost every page. After properly installing the Simplified Chinese fonts
          > (gb2312) on all of the users PC?s via the Regional and Language setting, the
          > pages display both languages properly.

          why not simply use utf-8?

          > No matter what we do, all we see in the PDF file where the Chinese characters
          > should be are ???.

          if you mean question marks (not sure, the newsgroups have rendered a lot of your
          text as question marks) that means your data got garbaged by a fatal encoding
          error (a box/square means the s/w can't render that char using the selected font).

          while you've installed fonts, etc. did you change your app's encoding? cf6 &
          above default to utf-8, if your text/data is gb2312 & you're not telling cf
          that's the encoding, it could be the source of your problem. or could be a db
          issue. where's the text coming from?
          • 2. Re: &lt;cfdocument&gt; not showing Chinese character
            PHRED-SE Level 1
            A. The Chinese characters display fine in the HTML format so the data from the database is not at fault nor is the data garbled.

            B. The fact that it worked with CF MX7 and does not work with CF8 leads me to believe that there is some setting in CF8 that is not correct or that there may be a bug in CF8 when it comes to building PDF files with Chinese character in them.

            C. Until I set up my client PC to work with Asian Languages in Regional and Language section of Windows, the characters would not display properly in I.E. so I'm not sure how UTF-8 would have solved this problem.

            D. Not sure what you mean by, "if your text/data is gb2312 & you're not telling cf that's the encoding". Could you either explain what you mean by this statement or tell me how to do this.

            Thanks for your suggestions.

            :-}
            Len
            • 3. Re: &lt;cfdocument&gt; not showing Chinese character
              Level 7
              PHRED-SE wrote:
              > A. The Chinese characters display fine in the HTML format so the data from the
              > database is not at fault nor is the data garbled.

              are the HTML pages being converted to PDF as is or is the data for the PDF
              coming from a db?

              the *fact* that you have question marks in your text tells me the data is
              garbaged as a result of an encoding problem. you just need to find where that's
              occurring.

              > B. The fact that it worked with CF MX7 and does not work with CF8 leads me to
              > believe that there is some setting in CF8 that is not correct or that there may
              > be a bug in CF8 when it comes to building PDF files with Chinese character in
              > them.

              proves nothing of the sort. you can have any number of things setup differently
              or code changes between servers. it's more often the case than not.

              > C. Until I set up my client PC to work with Asian Languages in Regional and
              > Language section of Windows, the characters would not display properly in I.E.
              > so I'm not sure how UTF-8 would have solved this problem.

              if you used unicode, ms has plenty of default installed fonts that can render
              CJK text, you would not have had to run around installing fonts. you would have
              used a W3C recommended encoding & cf's default encoding & not needed to swim
              against the tide. you could have embedded the fonts in the PDF....i can go on
              all day.

              > D. Not sure what you mean by, "if your text/data is gb2312 & you're not
              > telling cf that's the encoding". Could you either explain what you mean by
              > this statement or tell me how to do this.

              cfprocessingdirective.

              also read the cfdocument docs as to how & what parts of CSS are supported,
              iText's HTML & CSS support have limitations.
              • 4. Re: &lt;cfdocument&gt; not showing Chinese character
                PHRED-SE Level 1
                I see what you are saying about utf-8. I put in a cfprocessingdirective tag in order to use utf-8 encoding, but it makes no apparent difference. I also tried using other canonical values (MS936, x-mswin-936, etc.) for Simplified Chinese that I found in a Java spec on the Sun website – still not difference. Well that’s not strictly true: when I used Cp935, it turned everything to Chinese characters.

                After working with the utr-8 and doing some other analysis we discovered the questions marks in the code were not being cause by unprintable characters, but they we actually in the data. OOOOPs.

                This is a whole new ballgame. At first we though that the servers running CF8 must be missing some font that was needed on the server side. We brought over all of the fonts that seemed to be associated with Simplified Chinese, but that didn’t make any difference. I one final act of desperation, we changed the format on the cfdocument from PDF to SWF. All of the Chinese characters appeared in the SWF output file. All of the Chinese characters also appear in the HTML output that is generated at the same time that the PDF/SWF files are created. I call the code that creates the actual report twice from within a shell: once inside the cfdoument with a file name to create a separate file, and once that is not within it to create a HTML presentaion.

                The same code, when run on a CF7 server, produces a PDF output with all of the Chinese characters. One last thing, we are using CF8 on two different servers: one running W2KS and the other with W2003S.

                The only thing I can conclude from all of this is that there is either something wrong with the CF8 setup on both servers, or there is something wrong with CF8 itself.

                I'm also in the middle of a severe Verity problem that I'm working on with Adobe. The K2Server.exe process will crash (process grows from about 15k to over 700,000k) after doing some number of Verity collection creations or in the indexing. I've sent them code that will create this problem time after time. They are still scratching their collective heads over this one. I see it as a classic case of memory leakage. They haven't agreed with me yet. Having said all that, it seems entirely possible that there is some undiscovered problem with cfdocument and PDF file creation using CF8 as well.

                :-}
                Len
                • 5. Re: &lt;cfdocument&gt; not showing Chinese character
                  Level 7
                  PHRED-SE wrote:
                  > order to use utf-8 encoding, but it makes no apparent difference. I also

                  unless your data is also in utf-8 it won't or it would make things "worse".

                  > The same code, when run on a CF7 server, produces a PDF output with all of the
                  > Chinese characters. One last thing, we are using CF8 on two different servers:
                  > one running W2KS and the other with W2003S.

                  can i get a look at a simple example? text & code?

                  • 6. Re: &lt;cfdocument&gt; not showing Chinese character
                    PHRED-SE Level 1
                    After I was unable to get this to work no matter what I tried, I made a trouble call to Adobe in early February. After working with them for over two months, they finally determined that the reason the Chinese characters would not appear in the PDF file was because I had two True Type Collection files (SimSun.ttc and MingLiu.ttc) installed on my server. iText can not work with ttc fonts. I removed these two files, which turned out to be no easy job, and the Chinese characters now appear in the PDF file.

                    We’re not completely home free, however. The embedded fonts, whatever they are, must be bitmaps because the size of the file increased 3000%; i.e., approx 500k to 15 mbytes. This sort of defeats the whole purpose of having the PDF file since my customer’s email system prevents them from sending/receiving files larger than 5 mbytes!!!

                    If I turn off the <cfdocument>’s embedded feature, then there is just a long series of black dots where the characters should be. I’m waiting for Adobe to get back to me with the name of the font that iText embeds in the PDF document. I’m hoping that this font is something I don’t have on my client PC and that adding it to my client PC will replace the black dots with the proper Chinese characters. This seems unlikely since I have 260 font files on the client PC. But one can always hope that things will all turn out well in the end.

                    The ttc issue would apply to any language that you are trying to embed in a PDF document. There were seven ttc font files on my server so if you are having this problem with another language, determine what font file is being used and see if it is a ttc font.
                    • 7. Re: &lt;cfdocument&gt; not showing Chinese character
                      PHRED-SE Level 1
                      After we got the Chinese characters to show up in the PDF files by removing the the two ttc fonts (SimSun.ttc and MingLiu.ttc), the PDF files grew by 3000% -- from 0.5 mbytes to 15 mbytes. This problem was resolved by upgrading to CF 8.0.1. Now all is well.

                      Like to thank Adobe's support team for determining that it was the xxx.ttc fonts that was the problem.

                      :-}}}}}}}}}}}}
                      Len
                      • 8. Re: &lt;cfdocument&gt; not showing Chinese character
                        KWH Gordon Level 1
                        I have the same case, but i can not delete the ttc fonts, which may use by other system.
                        Indeel, i am feeling problem on the CF8, CF7 is work fine. And delete the ttc fonts is do not make sence.
                        Anyway, i already installed 8.01, also not work. How can i filter *.ttc let coldfusion not load the ttc fonts?
                        • 9. Re: &lt;cfdocument&gt; not showing Chinese character
                          PHRED-SE Level 1
                          We found out about removing the ttc fonts from Adobe. They worked on the problem based upon a trouble call we made for a couple of months and finally determined that systems with ttc fonts would not show the Chinese characters in PDF files created on servers that had them installed.. After we removed the SimSum.ttc and MingLiu.ttc fonts from both of our systems, the Chinese characters showed up on the PDF files created on these two systems.

                          The upgrade from 8.0 to 8.1 only reduced the size of the PDF files created as I outline in my 5/6/08 post.