Feature #17570

use rbpdf gem instead of bundled rfpdf

Added by Jun NAITOH over 3 years ago. Updated almost 3 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Toshi MARUYAMA% Done:

0%

Category:PDF export
Target version:2.6.0
Resolution:Fixed

Description

I updated rfpdf base version to TCPDF 5.1.002 from 1.53.0.TC031 for Redmine trunk.

main feature

  • Use UTF-8 encoding.
  • RTL (Right-To-Left) languages support was added.
  • HTML tag inside table supported.
  • CSS minimum support.
  • Bookmark support.
  • Adhoc Thai language support. (Bold font not support)
  • Image
    • 8bit PNG image support without RMagick liblary.
    • 16bit PNG image support. (use RMagick liblary)
    • Alpha channel PNG image adhoc support. (use RMagick liblary)
    • JPEG image support. (use RMagick liblary)
    • GIF image support. (use RMagick liblary)

fixed issues

  • #8753 : RTL languages supoorted.
  • #14466 : This patch fixed.
  • #13860 : This patch fixed.
  • #13589 : default_table_columns parameter is invalid now.
  • #14599 : Support 16-bit depth PNG images with RMagick libray.
  • #12934 : Support images in tables.
  • #14917 : Supported style of center at Table.

fixed issues (adhoc)

  • #12934 : Supported style of text-align right/center/left attribute, but no vertical-align attribute, yet.
  • #12447 : Convert alpha channel to black.

Gem file

gem install rfpdf

patch

  • lib_redmine.rb_r13333.patch : Gantt/Issues list/Issue/Wiki PDF export patch.
  • config_localse_r13333.patch : general_pdf_encoding is set UTF-8 locale.

my testing environment

  • Redmine trunk (r13333)
  • Ruby 1.8.7-p352/1.9.3-p392/2.0.0-p247/2.1.2
  • CentOS 6/Windows 7

Thanks!

lib_redmine.rb_r13333.patch Magnifier (31.8 KB) Jun NAITOH, 2014-07-28 17:30

config_localse_r13333.patch Magnifier (2.78 KB) Jun NAITOH, 2014-07-28 17:30

planio_logo_button_250_no_shadow.png (9.67 KB) Felix Schäfer, 2014-07-31 15:52

config_localse_r13339.patch Magnifier (2.78 KB) Jun NAITOH, 2014-08-18 00:57

lib_redmine.rb_r13339.patch Magnifier (32.1 KB) Jun NAITOH, 2014-08-18 00:57

rbpdf_example042.pdf (93.9 KB) Jun NAITOH, 2014-08-19 23:15

gantt.png (15.6 KB) m mahdi, 2014-11-29 16:12

issues.png (13.6 KB) m mahdi, 2014-11-29 16:12


Related issues

Related to Redmine - Defect #13781: CJK(Chinese/Japanese/Korean) characters are not shown in ... Closed
Related to Redmine - Defect #13642: PDF bookmark not displayed when contain a non-ascii chara... Closed

Associated revisions

Revision 13357
Added by Toshi MARUYAMA about 3 years ago

ensure issue pdf test has relations (#17570)

Revision 13358
Added by Toshi MARUYAMA about 3 years ago

use rbpdf gem instead of bundled rfpdf (#17570)

Contributed by Jun NAITOH.

Revision 13359
Added by Toshi MARUYAMA about 3 years ago

remove general_pdf_encoding from lib/redmine/export/pdf.rb (#17570)

Revision 13360
Added by Toshi MARUYAMA about 3 years ago

remove general_pdf_encoding from locale yamls (#17570)

Revision 13409
Added by Toshi MARUYAMA about 3 years ago

Gemfile: update rbpdf version to 1.18.1 (#17570)

History

#1 Updated by Jun NAITOH over 3 years ago

I forgot the following additional procedure, Sorry.

  • remove lib/plugins/rfpdf/

#2 Updated by Etienne Massip over 3 years ago

  • Target version set to Candidate for next major release

Thank you very much, because I looked for working on this I know it's a lot of work. Very nice.

Do you have some way to keep the new code updated compared to TCPDF, like some howto/instructions that could be shared?

Just one thing, the rfpdf name should be definitely removed if the code is no more based upon this deprecated library.

#3 Updated by Felix Schäfer over 3 years ago

Thank your for the patch. I can confirm that many things work, for example images in a table, unfortunately png images with an alpha channel seem to still be problematic.

We have tried out the patch for one of our customers at Planio, they have png images that currently do not work at all. With the patch, the pdf is rendered with the space for the image, but depending on the pdf viewer it will either show empty space (for example Preview.app on a Mac) or a greyscale distorted version of the png (Chromium on a Mac).

Jun, would it help you to have an image that has the above problems with which you can try it out? I will try to see with our customer if we can generate a problematic png that we can share.

#4 Updated by Felix Schäfer over 3 years ago

In fact our own logo with an alpha channel shows the same problem. I have attached it to this issue, feel free to use it to test, thanks.

#5 Updated by Jun NAITOH over 3 years ago

Etienne Massip wrote:

Do you have some way to keep the new code updated compared to TCPDF, like some howto/instructions that could be shared?

It is the following three that I thought as important.
  • Maintain the state of operating.
  • Update only the required range.
  • A PDF output result should become the same as that of TCPDF.
    Therefore, I translated into Ruby, pursuing the repository revision history of TCPDF.

Just one thing, the rfpdf name should be definitely removed if the code is no more based upon this deprecated library.

OK, I change the rfpdf gem name into another name.
Thank you for the advice.

#6 Updated by Jun NAITOH over 3 years ago

Felix Schäfer wrote:

unfortunately png images with an alpha channel seem to still be problematic.

Yes, I agree with you.

Jun, would it help you to have an image that has the above problems with which you can try it out?

Yes, I'll try it.

#7 Updated by Jun NAITOH over 3 years ago

I updated patch and gem.

  • rfpdf product name and TCPDF class name changed to RBPDF.
  • PNG alpha channel image support. (need RMagick.)

Gem file

gem install rbpdf

patch

  • lib_redmine.rb_r13333.patch : Gantt/Issues list/Issue/Wiki PDF export patch.
  • config_localse_r13333.patch : general_pdf_encoding is set UTF-8 locale.
  • remove lib/plugins/rfpdf/

#8 Updated by Felix Schäfer over 3 years ago

Jun NAITOH wrote:

I updated patch and gem.

Thanks!

  • PNG alpha channel image support. (need RMagick.)

I cannot confirm, my 2 png test files with alpha channel did not get rendered into the PDF at all. Have you tried it with the file attached to note 4? If the file attached in file 4 gets rendered to PDF for you, I would try to see why it doesn't work for me.

#9 Updated by Jun NAITOH over 3 years ago

  • PNG alpha channel image support. (need RMagick.)

I cannot confirm, my 2 png test files with alpha channel did not get rendered into the PDF at all.
Have you tried it with the file attached to note 4?

Yes. Please show rbpdf_example042.pdf

Please tell me, your environment.
  • Ruby version
  • OS (Windows/Linux/etc.. )
  • RMagick version

my testing environment for this rbpdf_example042.pdf

  • CentOS Linux release 6.0 (i386)
  • Ruby 1.8.7-p374/ruby-1.9.2-p290/1.9.3-p392/2.0.0-p247/2.1.2
  • rmagick 2.13.2

#10 Updated by Felix Schäfer over 3 years ago

Jun NAITOH wrote:

Yes. Please show rbpdf_example042.pdf

That looks good indeed. Is this just rbpdf or from a Redmine wiki page? My test was trying to export a PNG with alpha channel transparency included in a wiki page in Redmine, can you confirm this works too for you?

Please tell me, your environment.
  • Ruby version
  • OS (Windows/Linux/etc.. )
  • RMagick version

ruby 2.1.2p95
OS X 10.9.4
rmagick (2.13.2)

#11 Updated by Felix Schäfer over 3 years ago

I will try to see where in the Redmine code it fails on my machine.

#12 Updated by Toshi MARUYAMA about 3 years ago

  • Tracker changed from Patch to Feature
  • Subject changed from rfpdf gem patch to use rbpdf gem instead of bundled rfpdf

#13 Updated by Toshi MARUYAMA about 3 years ago

  • Target version changed from Candidate for next major release to 2.6.0

#14 Updated by Toshi MARUYAMA about 3 years ago

  • Related to Defect #13781: CJK(Chinese/Japanese/Korean) characters are not shown in PDF on non CJK locales added

#15 Updated by Toshi MARUYAMA about 3 years ago

I have committed in trunk from r13357 to r13360.

Jun, can you fix #13781?

#16 Updated by Jun NAITOH about 3 years ago

Toshi MARUYAMA wrote:

I have committed in trunk from r13357 to r13360.

Thanks!

Jun, can you fix #13781?

I commented to #13781#note-10
I will solve this problem, if there is a font setting function.

However, the comment of #4787#note-9 worries me.

#17 Updated by Felix Schäfer about 3 years ago

Jun, I was able to test this a little more and the error I get is caused by an endless loop. The error is:

pdf: Image: error: File name too long @ rb_sysopen - /some/path/redmine/tmp/20140903-35375-hkom8b_20140903-35375-hi2xft_20140903-35375-vt1hl5_20140903-35375-11px1pc_20140903-35375-2peiit_201
40903-35375-1qg14l0_20140903-35375-1q2be3d_20140903-35375-1mwkgqu_140731155010_planio_logo_button_250_no_shadow.png.png.png.png.png.png.png.png.png

It seems rmagick on my system (OS X 10.9.4, ruby-2.1.2, rmagick-2.13.3, ImageMagick 6.8.9-5 Q16 x86_64 2014-07-25) creates png images with an alpha channel even if it is not needed. The tempfile_plain created in https://github.com/naitoh/rbpdf/blob/1.18.0/lib/rbpdf.rb#L5191-L5204 still has an alpha channel:

% identify -format '%[channels]' /some/path/redmine/tmp/20140903-36796-4vbykd_140731155010_planio_logo_button_250_no_shadow.png.png
srgba

(the 2 files were from 2 different runs, but you get the idea)

This in turn causes https://github.com/naitoh/rbpdf/blob/1.18.0/lib/rbpdf.rb#L5199 to try to remove the alpha channel again and to go into a loop where #Image will call #ImagePngAlpha and #ImagePngAlpha will call #Image.

Is there more information or a test I can do to help you?

#18 Updated by Jun NAITOH about 3 years ago

Felix Schäfer wrote:

Jun, I was able to test this a little more and the error I get is caused by an endless loop.

OK, this problem (#note-17 and #note-4) reproduced in my environment. (MAC OS X 10.8.5/ruby 2.1.2/rmagick 2.13.3).

I think that the cause of this problem is RMagick of Mac.

This in turn causes https://github.com/naitoh/rbpdf/blob/1.18.0/lib/rbpdf.rb#L5199 to try to remove the alpha channel again and to go into a loop where #Image will call #ImagePngAlpha and #ImagePngAlpha will call #Image.

Yes.

Is there more information or a test I can do to help you?

No.
I understood this problem, now.
Thanks!

I will fix this problem in the possible range.
Please wait several days.

#19 Updated by Felix Schäfer about 3 years ago

Jun NAITOH wrote:

Felix Schäfer wrote:

Jun, I was able to test this a little more and the error I get is caused by an endless loop.

OK, this problem (#note-17 and #note-4) reproduced in my environment. (MAC OS X 10.8.5/ruby 2.1.2/rmagick 2.13.3).
I understood this problem, now.
Thanks!

Great to hear!

Please wait several days.

No pressure, thanks for the hard work on the PDF exports.

#20 Updated by Jun NAITOH about 3 years ago

I released rbpdf 1.18.1 gem.

#note-17 and #note-4 problem fixed.

Thanks!

#21 Updated by Filou Centrinov about 3 years ago

  • Related to Defect #13642: PDF bookmark not displayed when contain a non-ascii character added

#22 Updated by Jean-Philippe Lang about 3 years ago

  • Assignee set to Toshi MARUYAMA

Toshi, can we close this one?

#23 Updated by Toshi MARUYAMA about 3 years ago

Jean-Philippe Lang wrote:

Toshi, can we close this one?

I think we can close this issue.
But, I don't know why #12934 and #12447 are adhoc in description.
Jun, could you post status in each issues?

#24 Updated by Jun NAITOH about 3 years ago

Status Update.

main feature

  • Use UTF-8 encoding.
  • RTL (Right-To-Left) languages support was added.
  • HTML tag inside table supported.
  • CSS minimum support.
  • Bookmark support.
  • Adhoc Thai language support. (Bold font not support)
  • Image
    • 8bit PNG image support without RMagick liblary.
    • 16bit PNG image support. (use RMagick liblary)
    • Alpha channel PNG image support. (use RMagick liblary)
    • JPEG image support. (use RMagick liblary)
    • GIF image support. (use RMagick liblary)

fixed issues

  • #8753 : RTL languages supoorted.
  • #14466 : This patch fixed.
  • #13860 : This patch fixed.
  • #13589 : default_table_columns parameter is invalid now.
  • #14599 : Support 16-bit depth PNG images with RMagick libray.
  • #12934 : Support images in tables.
  • #14917 : Supported style of center at Table.
  • #12447 : Supported PNG alpha channel (by rbpdf 1.18.1)
  • #11788 : Supported style of text-align right/center/left attribute. (vertical-align attribute don't support.)

I think we can close this issue, too.

Jun NAITOH wrote:

fixed issues (adhoc)

#12934 : Supported style of text-align right/center/left attribute, but no vertical-align attribute, yet.

Sorry, I miswrote Issue ID. #12934 is wrong, #11788 is right.
#12934 is already fixed.
And, I think to fixed #11788 , too.

#12447 : Convert alpha channel to black.

Already fixed by rbpdf 1.18.1

Thanks!

#25 Updated by Toshi MARUYAMA about 3 years ago

  • Status changed from New to Closed
  • Resolution set to Fixed

Thank you!

#26 Updated by m mahdi almost 3 years ago

I update Redmine to 2.6.0
PDF Export for Arabic and Persian language was cluttered.
I attached exported files screenshots.

#27 Updated by Toshi MARUYAMA almost 3 years ago

m mahdi wrote:

I update Redmine to 2.6.0
PDF Export for Arabic and Persian language was cluttered.
I attached exported files screenshots.

Duplicate of #10681 and #16040.

Also available in: Atom PDF