GithubHelp home page GithubHelp logo

naitoh / rbpdf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from edwinmoss/rfpdf

29.0 29.0 21.0 16.14 MB

Ruby on Rails TCPDF plugin

License: GNU Lesser General Public License v2.1

Ruby 99.73% PHP 0.27%
html pdf pdf-generation rails ruby

rbpdf's People

Contributors

ahorek avatar akzhan avatar art-solopov avatar bmoss avatar edwinmoss avatar hanachin avatar jkraemer avatar marutosi avatar myabc avatar naitoh avatar nanego avatar ogerman avatar shovanj avatar skalimer0 avatar yui-har avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rbpdf's Issues

Redmine 4.2.1 error export to pdf

Нelp me please
`Started GET "/projects/smartool-dposm/wiki.pdf?utf8=%E2%9C%93&pdf%5Borientation%5D=1" for 95.221.54.79 at 2022-01-20 06:19:20 +0300
Processing by WikiController#show as PDF
Parameters: {"utf8"=>"✓", "pdf"=>{"orientation"=>"1"}, "project_id"=>"smartool-dposm"}
Current user: viktordemo (id=51)
Rendering wiki/show.pdf.erb
Deface: 'wiki-show-bottom' matched 0 times with 'p.wiki-update-info'
Rendered wiki/show.pdf.erb (143.8ms)
Completed 500 Internal Server Error in 167ms (ActiveRecord: 3.8ms)

ActionView::Template::Error (RBPDF error: Unsupported image type: webp):
1: <%= raw wiki_page_to_pdf(@page, @project) %>

plugins/redmine_reporting/app/models/reporting_pdf/pdf_renderer.rb:127:in render_pdf_header' plugins/redmine_reporting/app/models/reporting_pdf/pdf_renderer.rb:88:in make_pdf'
plugins/redmine_reporting/app/helpers/reporting_export_helper.rb:57:in reporting_make_pdf' plugins/redmine_reporting/app/helpers/reporting_export_helper.rb:94:in wiki_page_to_pdf'
app/views/wiki/show.pdf.erb:1:in _app_views_wiki_show_pdf_erb___1217950578384769169_47286679215120' plugins/redmine_reporting/lib/redmine_reporting/sweeper.rb:16:in around'
plugins/redmine_reporting/lib/redmine_reporting/sweeper.rb:16:in around' lib/redmine/sudo_mode.rb:61:in sudo_mode'
`

backslashes are duplicated in a table

\ shows as \\. There's some replacing of backslashes that I don't understand, but the attached patch shows where the problem is. [rbpdf.patch.txt](https://github.com/naitoh/rbpdf/files/783498/rbpdf.patch.txt)

Typo in rbpdf.rb?

In the rbpdf.rb file, we are using curly brackets {} instead of brackets [] to access second character of a string: https://github.com/naitoh/rbpdf/blob/master/lib/rbpdf.rb#L11033

if attrib{1} == ':'  # pseudo-element
          # pseudo-elements are not supported!
          # (::first-line, ::first-letter, ::before, ::after)
        else # pseudo-class

Do you know why? This cause an error on my app.

[1] pry(main)> s = "test"
=> "test"
[2] pry(main)> s[1]
=> "e"
[3] pry(main)> s{1}
NoMethodError: undefined method `s' for main:Object

Please bundle the source of ttf2ufm

Source code for tt2ufm is missing from the gem and the provided binaries are limited. The gem should not bundle pre-compiled binaries, but compile them at install time.

unclear license information

Hi,

I am packaging rbpdf for Debian as a dependency of redmine, but the licensing information in the source tree is very confusing.

In the git repository, LICENSE.TXT says LGPL, MIT-LICENSE says "MIT license". Can you please clarify exactly what parts are under the LGPL, and what parts are under the MIT license?

Also, in the .gem file thats is actually distributed via rubygems.org, only LICENSE.TXT is shipped.

Turkish language support and pangram for (utf8test.txt)

Hi,

I'm not sure, maybe my configuration is not correct. But it seems Turkish language support is a bit problematic. I have to say just tested in redmine.

There are some characters in Turkish that are not available in other latin alphabets.

If you need something for future analysis I can try help you.

Turkish (tr)

Pijamalı hasta, yağız şoföre çabucak güvendi.
(= The patient in pajamas quickly trusted the swarthy driver.)

Saf ve haydut kız çocuğu bin plaj görmüş.
(= The naive and thuggish little girl has seen a thousand beaches.)

PDF is broken on iOS

http://www.redmine.org/issues/19095

This is /CropBox's Problem.

  • Wrong example (rbpdf 1.18.5)
    /MediaBox [0.00 0.00 595.28 841.89] /CropBox [0.00 0.00 1687.41 2386.46] /BleedBox [0.00 0.00 4783.20 6764.77] /TrimBox [0.00 0.00 4783.20 6764.77] /ArtBox [0.00 0.00 4783.20 6764.77]
  • Correct example
    /MediaBox [0.00 0.00 595.28 841.89] /CropBox [0.00 0.00 595.28 841.89] /BleedBox [0.00 0.00 595.28 841.89] /TrimBox [0.00 0.00 595.28 841.89] /ArtBox [0.00 0.00 595.28 841.89]

Various warnings about operators

Problem Description:

C:\Users\Josh\Downloads\redmine\redmine-3.3.2>bundle exec rails server webrick -
e production
C:/Applications-64bit/jruby-9.1.8.0/lib/ruby/gems/shared/gems/rbpdf-1.19.0/lib/r
bpdf.rb:5020: warning: `-' after local variable or literal is interpreted as bin
ary operator
C:/Applications-64bit/jruby-9.1.8.0/lib/ruby/gems/shared/gems/rbpdf-1.19.0/lib/r
bpdf.rb:5020: warning: even though it seems like unary operator
C:/Applications-64bit/jruby-9.1.8.0/lib/ruby/gems/shared/gems/rbpdf-1.19.0/lib/r
bpdf.rb:5834: warning: `+' after local variable or literal is interpreted as bin
ary operator
C:/Applications-64bit/jruby-9.1.8.0/lib/ruby/gems/shared/gems/rbpdf-1.19.0/lib/r
bpdf.rb:5834: warning: even though it seems like unary operator
C:/Applications-64bit/jruby-9.1.8.0/lib/ruby/gems/shared/gems/rbpdf-1.19.0/lib/r
bpdf.rb:6822: warning: `**' after local variable or literal is interpreted as bi
nary operator
C:/Applications-64bit/jruby-9.1.8.0/lib/ruby/gems/shared/gems/rbpdf-1.19.0/lib/r
bpdf.rb:6822: warning: even though it seems like argument prefix
C:/Applications-64bit/jruby-9.1.8.0/lib/ruby/gems/shared/gems/rbpdf-1.19.0/lib/r
bpdf.rb:9283: warning: `-' after local variable or literal is interpreted as bin
ary operator
C:/Applications-64bit/jruby-9.1.8.0/lib/ruby/gems/shared/gems/rbpdf-1.19.0/lib/r
bpdf.rb:9283: warning: even though it seems like unary operator
C:/Applications-64bit/jruby-9.1.8.0/lib/ruby/gems/shared/gems/rbpdf-1.19.0/lib/r
bpdf.rb:9331: warning: `-' after local variable or literal is interpreted as bin
ary operator
C:/Applications-64bit/jruby-9.1.8.0/lib/ruby/gems/shared/gems/rbpdf-1.19.0/lib/r
bpdf.rb:9331: warning: even though it seems like unary operator
C:\Users\Josh\Downloads\redmine\redmine-3.3.2>jruby -v
jruby 9.1.8.0 (2.3.1) 2017-03-06 90fc7ab Java HotSpot(TM) 64-Bit Server VM 25.12
1-b13 on 1.8.0_121-b13 +jit [mswin32-x86_64]

This is probably an issue Ruby's parsing and warning system itself, but I resolved it in the module adding a space after each operator, e.g.

Original:

out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q', w * @k, h * @k, xkimg, (@h -(y + h)) * @k, info['i']))

New (change "@h -(y+h)" to "@h - (y+h))"):

out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q', w * @k, h * @k, xkimg, (@h - (y + h)) * @k, info['i']))

Allow test suite to be run outside of a Rails instance

Hello, I'm packaging rbpdf for Gentoo Linux, and we let our users run the test suite when a ruby package is installed. But during this install process, we don't have a Rails instance available!

The test suite for rbpdf is almost independent of Rails, but there are a few places where the Rails class is used, and a few requires that are needed to run outside of a Rails environment. I made some progress on this myself at https://github.com/orlitzky/rbpdf/commit/3b797a2d4da8b615046c859dd0a8bb645c88c70a. With those changes, I can run the tests from a clean git checkout anywhere on the filesystem:

$ testrb-2 -Ilib test/*.rb
Loaded suite [test/rbpdf_bidi_test.rb, test/rbpdf_bookmark_test.rb, test/rbpdf_cell_test.rb, test/rbpdf_content_test.rb, test/rbpdf_css_test.rb, test/rbpdf_dom_test.rb, test/rbpdf_font_func_test.rb, test/rbpdf_font_style_test.rb, test/rbpdf_font_test.rb, test/rbpdf_format_test.rb, test/rbpdf_func_test.rb, test/rbpdf_htmlcell_test.rb, test/rbpdf_html_func_test.rb, test/rbpdf_html_test.rb, test/rbpdf_image_rmagick_test.rb, test/rbpdf_image_test.rb, test/rbpdf_test.rb, test/rbpdf_transaction_test.rb, test/rbpdf_viewerpreferences_test.rb, test/rbpdf_write_test.rb, test/test_helper.rb]
Started
...................................................

Finished in 5.278041106 seconds.
--------------------------------------------------------------------------------
51 tests, 474 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
0% passed
--------------------------------------------------------------------------------
9.66 tests/s, 89.81 assertions/s

You will probably want a cleaner fix (and I get a warning about ng.png) but I think this should be possible without intrusive changes.

rbpdf causes "RMagick" deprecation warning in rake tasks ?

Whenever I run a rake command from the prompt, I get the message:
[DEPRECATION] requiring "RMagick" is deprecated. Use "rmagick" instead

I do have rmagick gem 2.15.4, rbpdf 1.18.6 in my gems, and "bundle install" tells me I'm using those versions.

I tried removing line 64 of file /usr/local/rvm/gems/ruby-2.0.0-p247/gems/rbpdf-1.18.6/lib/rbpdf.rb, and the warning does go away.

However, on my test machine, I don't have the warning even though I did not touch the rbpdf gem.

I really wonder why there is a difference between my test machine and my production server, but anyway, I can't keep that warning popping up, because it generates mails for all my cron rake tasks, even though they are successful, which creates tons of useless mails (I run rake tasks for checking incoming mails every 5 minutes).

So:

  1. Should rbpdf really try to load "RMagick" if it failed loading "rmagick" ?
  2. Would you have any hint on why rmagick would be loaded in one of my rake environments and not in the other?

I'm using Linux centOS, and the test machine is originally a copy of the production machine, on which I only updated gems and Rails regularly. The server is used for hosting a Redmine web site (so it has Ruby on Rails and Redmine).

Best regards,
Olivier
PS : if you want me to run some tests on the machine popping up the warning, I can do it.

invalid parenthesis code

I am writting html code "(Global positioning System)".. so rbpdf writes in utf8 mode "....a GPS #!#OP#!#Global Positioning System#!#CP#!#, homolo", how is possible ?

Tecnología GPS (Global Positioning System)

Image export pdf

Hello,

I'm working on a redmine platform and I want to upload image in my wiki and export it in pdf. The upload work fine but when I export the wiki in pdf their is no image ... I'm using CKeditor, this plugin use Rich (https://github.com/kreativgebiet/rich) to upload image. If I insert an image hosted on internet in my wiki, the pdf export works (thanks to https://github.com/ogerman/redmine_pdf_export) but if I use Rich module from CKeditor to upload the image the export pdf doesn't work.

My wiki

pdf_issue_1

My pdf

pdf_issue_2

Error

Processing by WikiController#show as PDF
Parameters: {"project_id"=>"default_project", "id"=>"Welcome_to_default_project"}
Current user: admin (id=1)
bad component(expected host component): localhost:3000
pdf: Image: error: RBPDF error: Image filename is empty.
Rendered wiki/show.pdf.erb (395.4ms)
Completed 200 OK in 414ms (Views: 397.0ms | ActiveRecord: 3.0ms)

My configuration

OS : centOS 6.5
Redmine : 3.1.0-0 (https://bitnami.com/stack/redmine/installer)
CKeditor : 1.1.2 (https://github.com/a-ono/redmine_ckeditor)

Any help will be greatly appreciated !

Robin

Infinite loop on oversize images.

Hi again
I found the scenario that makes an infinit loop!

#irb
html = '<p><img src="/somewhere/image.png" style="width:2000px;height:563px;"></p>'
r = RBPDF.new
r.add_page
r.set_rtl(true)
r.writeHTMLCell(0, 0, "", "", html)

If you decerase width to 1000px it works fine.

As I mentioned at the first message it is related to this code block in rbpdf.rb. But it's not related to src and existance of image, but related to oversize of image (that @skalimer0 told before 👍 ).

if (@rtl and (@x - imgw < @l_margin + @c_margin)) or (!@rtl and (@x + imgw > @w - @r_margin - @c_margin))
    # add automatic line break
    autolinebreak = true
    Ln('', cell)
    # go back to evaluate this line break
    key -= 1
end

My Environment:

$ruby -v
ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5) [x86_64-linux]

$gem list rbpdf
*** LOCAL GEMS ***
rbpdf (1.21.1, 1.21.0, 1.20.1)
rbpdf-font (1.19.1)

Originally posted by @salmanmp in #62 (comment)

Problem when rmagick transparent invalidation processing does not work on alpha 1-bit PNG images.

Problem when rmagick transparent invalidation processing does not work on alpha 1-bit PNG images.

When alpha 1-bit PNG image does not operate rmagick transparent invalidation processing, the behavior of RBPDF becomes abnormal.

This problem is https://www.redmine.org/issues/28125

Information on the image where the problem occurs.

http://www.redmine.org/attachments/download/3458/redmine_logo_v1.png

$ identify  -verbose test/redmine_logo_v1.png 
Image: test/redmine_logo_v1.png
  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: DirectClass
  Geometry: 600x200+0+0
  Resolution: 28x28
  Print size: 21.4286x7.14286
  Units: PixelsPerCentimeter
  Colorspace: sRGB
  Type: PaletteAlpha
  Base type: Undefined
  Endianess: Undefined
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 1-bit

In a problematic environment, you can not delete the alpha channel of this image with "img.alpha = Magick::DeactivateAlphaChannel".

https://github.com/naitoh/rbpdf/blob/1.19.3/lib/rbpdf.rb#L5130

No Problem Case

CentOS 6(x86)
ruby 2.4.0p0 (2016-12-24 revision 57164) [i686-linux]
ImageMagick-devel-6.5.4.7-5.el6.i686
ImageMagick-6.5.4.7-5.el6.i686
rmagick (2.16.0)

Problem Case

MacOS X Sierra(10.12.6)
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
ImageMagick 6.9.9-50
rmagick (2.16.0)

Incorrect characters when copying out of a generated PDF with Acrobat

Hello

Since this commit d961323 in version 1.19.4 PDF generated text can't be copy pasted using Adobe Acrobat Reader, only square symbols are pasted. A ticket has been opened on Redmine project see : https://www.redmine.org/issues/32740

Reverting the commit doesn't solve the issue either as the PDF become corrupted. It seems UTF-8 characters are translated to a speific unicode range that is not the one corresponding to the standard UTF-8 characters codes.

Regards,

Y. Savanier

When Colorspace is sRGB, processing of alpha PNG image fails.

This problem is https://www.redmine.org/issues/28125
This was fixed in #44, but since the correction was incorrect, I will fix it again.

  • Incompatible code in RGB color space and sRGB color space.
img = Magick::ImageList.new(file)
img2 = img.separate(Magick::OpacityChannel)
img = img2.negate(true)

The acquired alpha channel is used as a mask by reversing the value.
However, the response of the separate() method is reversed in RGB color space and sRGB color space.

No Problem Case (RGB Colorspace)

  • CentOS 6(x86)
  • ruby 2.4.0p0 (2016-12-24 revision 57164) [i686-linux]
  • ImageMagick-6.5.4.7-5.el6.i686 / ImageMagick-devel-6.5.4.7-5.el6.i686
    or
    ImageMagick-6.7.2.7-6.el6.i686 / ImageMagick-devel-6.7.2.7-6.el6.i686
  • rmagick (2.16.0)
$ identify  -verbose test/png_test_alpha.png 
Image: test/png_test_alpha.png
  Format: PNG (Portable Network Graphics)
  Class: DirectClass
  Geometry: 552x102+0+0
  Resolution: 28.35x28.35
  Print size: 19.4709x3.59788
  Units: PixelsPerCentimeter
  Type: TrueColorMatte
  Endianess: Undefined
  Colorspace: RGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 8-bit

Problem Case (sRGB Colorspace)

  • MacOS X Sierra(10.12.6)
  • ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
  • ImageMagick 6.9.9-50
  • rmagick (2.16.0)
$ identify  -verbose test/png_test_alpha.png 
Image: test/png_test_alpha.png
  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: DirectClass
  Geometry: 552x102+0+0
  Resolution: 28.35x28.35
  Print size: 19.4709x3.59788
  Units: PixelsPerCentimeter
  Colorspace: sRGB
  Type: TrueColorAlpha
  Base type: Undefined
  Endianess: Undefined
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 8-bit
  • CentOS 7.3 (x86_64)
  • ruby 2.4.1
  • ImageMagick-6.7.8.9-15.el7_2.x86_64 / ImageMagick-devel-6.7.8.9-15.el7_2.x86_64
  • rmagick (2.16.0)
$ identify  -verbose test/png_test_alpha.png
Image: test/png_test_alpha.png
  Format: PNG (Portable Network Graphics)
  Class: DirectClass
  Geometry: 552x102+0+0
  Resolution: 28.35x28.35
  Print size: 19.4709x3.59788
  Units: PixelsPerCentimeter
  Type: TrueColorAlpha
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 8-bit

Inifite loop

When try to export some html text that contains tag with invalid src attribute, it is gone into infinit loop.
May be this line causes that infinite loop.

rbpdf/lib/rbpdf.rb

Line 12173 in 838341d

key -= 1

Redmine: Customizing Fonts in Exported PDF

Hi,

Im using redmine and really need to customize the PDF export functionality thats done through rbpdf. However, I cant figure out how to customize the font when exporting Issues with Arabic (RTL) language content and text.

Can someone guide me to where the customizations need to be applied?

Thanks
Salim

released rbpdf 1.20.0 isn't built from the repository

gem install rbpdf
ERROR:  While executing gem ... (Errno::EINVAL)
    Invalid argument @ rb_sysopen - c:/mingw64/lib/ruby/gems/2.6.0/gems/rbpdf-1.20.0/test/json:

this looked suspicious to me, so I audited the gem. It doesn't contain any malicious code, but it was clearly not built against the github repository and there're some additional files, that breaks the installation.

for example
metadata contains
- 'test/json:'
test folder contains
json_
and there's no such file in the github repository

@naitoh could you fix the issue? imo, test files shouldn't be distributed at all. thanks

https://github.com/rubygems/rubygems/issues/2496

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.