naitoh / rbpdf Goto Github PK
View Code? Open in Web Editor NEWThis project forked from edwinmoss/rfpdf
Ruby on Rails TCPDF plugin
License: GNU Lesser General Public License v2.1
This project forked from edwinmoss/rfpdf
Ruby on Rails TCPDF plugin
License: GNU Lesser General Public License v2.1
Н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'
`
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
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.
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.
This problem is https://www.redmine.org/issues/28125#note-2
pdf: Image: error: RBPDF error: Image filename is empty.
Although I could not reproduce it, I corrected the processing which is considered as a cause.
I was closing the temporary file to save the file with RBPDF.
Therefore, there was a possibility that files were deleted when GC occurred.
Fixed to save file contents with fsync().
https://www.rubydoc.info/gems/rbpdf/1.18.3/RBPDF:Ln
@param float :h |
---|
The height of the break. By default, the value equals the height of the last printed cell. |
By default, the value is intended to be the height of the last printed cell.
However, the current implementation has become the height of the last printed by MultiCell.
This problem is http://www.redmine.org/issues/28565#note-10
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.
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.)
http://www.redmine.org/issues/19095
This is /CropBox's Problem.
rbpdf
gem has strict dependcy
"htmlentities" "=4.3.1"
Unfortunately htmlentitie has error in versions 4.3.1 and 4.3.2 where in file lib/htmlentities/mappings/expanded.rb
key inodot is defined twice. This error is removed in tag 4.3.3.
Hi,
Can you update htmlentities to 4.3.3 ?
I still got duplicated key warning like in threedaymonk/htmlentities#17
Thanks :D
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']))
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 require
s 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.
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:
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.
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 ?
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.
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)
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
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.
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
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
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)
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)
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
str = 'test'.force_encoding('UTF-8')
width = pdf.get_string_width(str)
str.encoding => ASCII-8bit
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.
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.
$ 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
$ 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
$ 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
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.
Line 12173 in 838341d
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
Relaying an issue that was mentioned by Jean-Philippe Lang in http://www.redmine.org/issues/14534#note-33:
the rbpdf gem uses ActionView::Base.sanitized_allowed_css_properties= which is deprecated in Rails 4.2
The method is called at https://github.com/naitoh/rbpdf/blob/master/lib/rbpdf.rb#L10688.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.