Defect #6505

PDF export broken with Japanese (Gannt and Issue Tracking)

Added by Leo Hourvitz about 7 years ago. Updated over 6 years ago.

Status:ClosedStart date:2010-09-27
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:PDF export
Target version:-
Resolution:Duplicate Affected version:1.0.1

Description

When exporting Gannts or Issue Lists to PDF, the Japanese-language text is garbled (the English-language text comes out fine). A sample image is attached.

I suspect this will be true of any PDF export, but those are the two exports I've tried this with.

Note that unlike the report regarding Hebrew, this is not true of CSV export for Issue Lists; those come out fine via the UTF-8 encoding.

  • CentOS 5.3
  • MySQL 5.0.77 (yes my charset is UTF-8)
  • ruby 1.8.7
  • Rails 1.2.6 (I think, I'm using the one that was packaged with redmine 1.0.1)

I'm in Tokyo so this would seem to rule out decent printing from Redmine. Because CSV export works, there's always that workaround for Issue Lists.

I've read about the GANTT rewrite, but the fact this is in issue list export as well suggests it's something more generic. I listed the two related reports, but I couldn't see anything where this was resolved.

JapaneseBecomesGarbage.png - A sample of the mangled output (9.93 KB) Leo Hourvitz, 2010-09-27 05:48

japanese.rb.patch Magnifier (2.82 KB) Jun NAITOH, 2011-03-21 04:12

korean.rb.patch Magnifier (3.29 KB) Jun NAITOH, 2011-03-21 04:12

chinese.rb.patch Magnifier (3.14 KB) Jun NAITOH, 2011-03-21 04:12

pdf.rb_utf8.patch Magnifier (9.79 KB) Jun NAITOH, 2011-03-22 22:24

gantt.rb_utf8.patch Magnifier (5.14 KB) Jun NAITOH, 2011-03-22 22:24

korean.rb_utf8.patch Magnifier (1.86 KB) Jun NAITOH, 2011-03-22 22:24

japanese.rb_utf8.patch Magnifier (1.05 KB) Jun NAITOH, 2011-03-22 22:24

chinese.rb_utf8.patch Magnifier (1.62 KB) Jun NAITOH, 2011-03-22 22:24


Related issues

Related to Redmine - Defect #5884: PDF export doesn't work for Hebrew Closed 2010-07-15
Related to Redmine - Feature #4699: Export PDF in Chinese and Japanese language is get well i... Closed 2010-01-31
Related to Redmine - Defect #7794: Internal server error on formatting an issue as a PDF in ... Closed 2011-03-06
Related to Redmine - Defect #4787: Gannt to PNG - CJK (Chinese, Japanese and Korean) charac... Closed 2010-02-10
Duplicates Redmine - Defect #61: Broken character encoding in pdf export Closed

History

#1 Updated by Leo Hourvitz about 7 years ago

Hmm, I just I can't add related issues if I'm not a Developer?

Anyway, the two related (but not identical) issues I see are:

  • #5884 Hebrew language export problem (but he couldn't export CSVs either?)
  • #4699 Chinese/Japanese export described as a feature? (I didn't understand the report clearly)

#2 Updated by Igor Velkov about 7 years ago

Same for russian: I try to save as pdf an issue with comments, and got pdf with russian garbled text.

#3 Updated by Toshi MARUYAMA about 7 years ago

In Japanese, Issue Tracking works fine.
Please see http://www.redmine.org/boards/2/topics/11734 .

But Gantt is broken at 1.0.2.

#4 Updated by John Yani almost 7 years ago

PDF enconding is a known bug of Redmine. See issue #61.

#5 Updated by Toshi MARUYAMA almost 7 years ago

#61 is UTF-8 and font problem.
"general_pdf_encoding" at source:/tags/1.0.4/config/locales/ja.yml#L159 is "CP932".
So, PDF for issue list has no problem as long as user uses only Japanese character and user locale is "ja".

But, Gannt is broken at 1.0.2.
This is related with #6348.

#6 Updated by Jun NAITOH over 6 years ago

This patch fixed the PDF export broken problem with Japanese/Chinese/Korean.
This is Rfpdf plugin's problem. Rfpdf plugin don't expect to input of UTF-8 character set....

Flow of PDF export broken problem (issue_to_pdf) in Japanese case.

  1. lib/redmine/export/pdf.rb : pdf.MultiCell (use UTF-8 character set)
  2. vendor/plugins/rfpdf/lib/rfpdf/japanese.rb : def MultiCell (expect SJIS character set input)
  3. vendor/plugins/rfpdf/lib/rfpdf/japanese.rb : Cell (expect SJIS character set output)
  4. lib/redmine/export/pdf.rb : def Cell (expect UTF-8 character set input)

MultiCell break UTF-8 3byte character.(Because, SJIS is 2byte character.)

Changed by this patch.

  1. lib/redmine/export/pdf.rb : pdf.MultiCell (use UTF-8 character set)
  2. vendor/plugins/rfpdf/lib/rfpdf/japanese.rb : def MultiCell (expect UTF-8 character set input)
  3. vendor/plugins/rfpdf/lib/rfpdf/japanese.rb : Cell (expect UTF-8 character set output)
  4. lib/redmine/export/pdf.rb : def Cell (expect UTF-8 character set input)

As for Chinese and Korean, it is similar.

My environment is as follows.

  • CentOS 5.5(x86)
  • Redmine 1.1.2
  • ruby 1.8.7
  • Rubygems 1.3.5
  • sqlite 3.3.6

#7 Updated by Toshi MARUYAMA over 6 years ago

  • Category changed from Issues to PDF export
  • Status changed from New to 7
  • Assignee set to Toshi MARUYAMA

#8 Updated by Toshi MARUYAMA over 6 years ago

  • Assignee deleted (Toshi MARUYAMA)

It seems an effect of note 6 patches is big.
I don't know about PDF, I remove assignee.

#9 Updated by Jun NAITOH over 6 years ago

Sorry, a effect of note 6 patches is big... I'm think so, too.
I want to reduce the patches's effect. so, I rewrote this patch.

This new patch don't change the rpdf plugin interface spec.

This is related to #1170 patch.

Changed by this rewritten patch.

  • UTF-8 input function added.
    • lib/redmine/export/pdf.rb : def UTF8MultiCell (expect UTF-8 character set input, and use iconv)
    • lib/redmine/export/pdf.rb : def UTF8Cell (expect UTF-8 character set input, and use iconv)
  • some minor fix.
    • tab character clash problem fix (japanese.rb only)
    • don't work 'explicit line break' problem fix (korean.rb only)
    • etc

#10 Updated by Toshi MARUYAMA over 6 years ago

Jun, thank you for your reply.
Are you Japanese? Do you live in USA? Patch timezone is "-0400".
I am Japanese and I live in Japan.

CJK PDF is very difficult.
I want to close this issue with duplicate of #61.
I can see issue watchers of this site.
Many users watch #61.

#11 Updated by Jun NAITOH over 6 years ago

I'm Japanese and live in Japan. Patch timezone is mistake, sorry.
I understand #61 issue, now.... so, it's very long....

I tested with English/Japanese/Chinese/Korean.
Because, I thought that the PDF export broken problem is CJK only.

But, #61 issue isn't CJK only.

OK, I will try to close #6505 and #61.

#12 Updated by Toshi MARUYAMA over 6 years ago

  • Status changed from 7 to Closed
  • Resolution set to Duplicate

Thank you posting new patch to #61.

Also available in: Atom PDF