rbpdf 1.19.0 → 1.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +10 -0
  3. data/Gemfile +4 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +16 -0
  6. data/Rakefile +4 -0
  7. data/lib/core/rmagick.rb +1 -1
  8. data/lib/rbpdf.rb +82 -47
  9. data/lib/rbpdf/version.rb +5 -1
  10. data/lib/rbpdf_encode_ok.rb +15170 -0
  11. data/lib/rbpdf_encode_ok2.rb +15178 -0
  12. data/lib/unicode_data.rb +18 -1
  13. data/rbpdf.gemspec +21 -5
  14. data/test/_rbpdf_image_test.rb_ +161 -0
  15. data/test/err_font1.rb +4 -0
  16. data/test/err_font2.rb +4 -0
  17. data/test/logo_rbpdf_8bit .png +0 -0
  18. data/test/logo_rbpdf_8bit+ .png +0 -0
  19. data/test/logo_rbpdf_8bit_/343/201/202/343/201/204/343/201/206/343/201/210/343/201/212.png +0 -0
  20. data/test/rbpdf_bidi_test.rb +76 -71
  21. data/test/rbpdf_bookmark_test.rb +38 -28
  22. data/test/rbpdf_cell_test.rb +120 -40
  23. data/test/rbpdf_content_test.rb +62 -45
  24. data/test/rbpdf_css_test.rb +275 -271
  25. data/test/rbpdf_dom_test.rb +123 -113
  26. data/test/rbpdf_font_func_test.rb +6 -2
  27. data/test/rbpdf_font_style_test.rb +7 -3
  28. data/test/rbpdf_font_test.rb +44 -27
  29. data/test/rbpdf_format_test.rb +15 -11
  30. data/test/rbpdf_func_test.rb +26 -22
  31. data/test/rbpdf_html_anchor_test.rb +11 -13
  32. data/test/rbpdf_html_func_test.rb +34 -30
  33. data/test/rbpdf_html_test.rb +58 -5
  34. data/test/rbpdf_htmlcell_test.rb +10 -6
  35. data/test/rbpdf_http_test.rb +67 -0
  36. data/test/rbpdf_image_rmagick_test.rb +70 -87
  37. data/test/rbpdf_image_test.rb +86 -22
  38. data/test/rbpdf_test.rb +88 -90
  39. data/test/rbpdf_transaction_test.rb +4 -0
  40. data/test/rbpdf_viewerpreferences_test.rb +5 -1
  41. data/test/rbpdf_write_test.rb +49 -45
  42. data/test/test_helper.rb +5 -0
  43. data/test_unicode.rbpdf +4 -0
  44. metadata +22 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6206e410a85c6ea47f3464985c9a4a8c6673974
4
- data.tar.gz: 43b4d2ce869cdab5244ed41582fcdcaaf269aa15
3
+ metadata.gz: 931120b760803ab55df75a98a64f8e44815f079a
4
+ data.tar.gz: 7b6137a01c62c40bf73d4801605afa6a053b050f
5
5
  SHA512:
6
- metadata.gz: 65e07e6d1a6a72cf760a6bf5492db77b08cd0ffa9dd32de92b65bb8ec5fff85b457c1c20ec28b4bce91a1b0216efa4f49292889995242cebf7bb6be16cbdeda6
7
- data.tar.gz: c77b80be9193f445da757904c8937f01714aea5be51f82156af113c1e521128cbb413b8533e9a52027b0b16444e59ebec473ec7d73c01d5f6f22da1fe2bad54b
6
+ metadata.gz: 2554dc1102b75b1b5f55f6fd1d348e55d059fb4338610d7dcdab5503f96ee3098d3eb91ab9225d63f240f4d5c400a22236f0c514df60d13c709862a1efab56f4
7
+ data.tar.gz: a20170d14ae2e0eaf8f34f974819c6fbae9a246395f4ceb5ccc9a8dff79b1734741718941880610f130c98c5065554cca57c39ec7594427511e62b9c1cc19d65
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ 1.19.1 2017-03-30
2
+ - Ruby 2.4 supported.
3
+ - Fixed get image file from remote URL
4
+ - Fixed get image file with Non-ASCII file name.
5
+ - Fixed function of SetFont bold/italic/bold and italic problem for CID-0 fonts.
6
+ - Fixed issue where backslash is duplicated in table tag. (by t-gergely)
7
+ - Fixed strict htmlentities dependency.
8
+ - Added the ability to specify abs-path font files. (by Artemiy Solopov)
9
+ - Use correct brackets to get second character in a string. (by vrobert)
10
+
1
11
  1.19.0 2015-11-20
2
12
  - Update base version to TCPDF 5.2.000.
3
13
  - IMPORTANT: Support for font subsetting was added by default to reduce the size of documents using large unicode font files.
data/Gemfile CHANGED
@@ -1,3 +1,7 @@
1
+ # Copyright (c) 2011-2017 NAITOH Jun
2
+ # Released under the MIT license
3
+ # http://www.opensource.org/licenses/MIT
4
+
1
5
  source 'https://rubygems.org'
2
6
 
3
7
  # Specify your gem's dependencies in rbpdf.gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2006 4ssoM LLC <www.4ssoM.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOa AND
17
+ NONINFRINGEMENT. IN NO EVENT SaALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -62,3 +62,19 @@ utf8test.txt
62
62
  logo_example.png
63
63
 
64
64
  ENJOY!
65
+
66
+ License
67
+
68
+ The project RBPDF doesn't use same license for all code. There are
69
+ code with:
70
+
71
+ * LGPLv2.1+ (GNU Lesser General Public License v2.1 or any later version)
72
+
73
+ * MIT (MIT-LICENSE)
74
+
75
+ Please, check source code for more details. A license is usually at the start
76
+ of each source file.
77
+
78
+ The MIT-LICENSE file (MIT) is the default license for code without an explicitly
79
+ defined license.
80
+
data/Rakefile CHANGED
@@ -1,3 +1,7 @@
1
+ # Copyright (c) 2011-2017 NAITOH Jun
2
+ # Released under the MIT license
3
+ # http://www.opensource.org/licenses/MIT
4
+
1
5
  require "bundler/gem_tasks"
2
6
  require 'rake/testtask'
3
7
 
@@ -25,7 +25,7 @@ module Rbpdf
25
25
 
26
26
  # http://uk2.php.net/getimagesize
27
27
  def getimagesize(filename)
28
- return nil unless File.exists?(filename)
28
+ return nil unless File.exist?(filename)
29
29
 
30
30
  out = Hash.new
31
31
  type = File::extname(filename)
@@ -50,6 +50,7 @@ require "rbpdf/version"
50
50
 
51
51
  require 'htmlentities'
52
52
  require 'rbpdf-font'
53
+ require 'erb'
53
54
 
54
55
  begin
55
56
  # RMagick 2.14.0
@@ -73,6 +74,7 @@ require 'rubygems' if RUBY_VERSION < '1.9' # Ruby 1.8.7
73
74
  require 'action_view'
74
75
  require 'tempfile'
75
76
  require 'uri'
77
+ require 'net/http'
76
78
 
77
79
  #
78
80
  # RBPDF Class.
@@ -256,7 +258,7 @@ class RBPDF
256
258
  # mb_internal_encoding("ASCII");
257
259
  # }
258
260
 
259
- if defined? Rails.root
261
+ if defined? Rails.root
260
262
  @@k_path_cache = Rails.root.join('tmp').to_s
261
263
  @@k_path_main = Rails.root.join('tmp').to_s
262
264
  @@k_path_url = Rails.root.join('tmp').to_s
@@ -289,6 +291,11 @@ class RBPDF
289
291
  @img_scale ||= 1
290
292
  @r_margin ||= 0
291
293
  @l_margin ||= 0
294
+ @original_r_margin ||= nil
295
+ @original_l_margin ||= nil
296
+ @t_margin ||= nil
297
+ @b_margin ||= nil
298
+ @auto_page_break ||= nil
292
299
  @page_annots ||= []
293
300
 
294
301
  @header_font ||= ['', '', 10]
@@ -308,6 +315,7 @@ class RBPDF
308
315
  @header_string ||= ""
309
316
  @listordered ||= []
310
317
  @listcount ||= []
318
+ @listnum ||= 0
311
319
  @listindent ||= 0
312
320
  @listindentlevel ||= 0
313
321
  @lispacer ||= ""
@@ -322,6 +330,7 @@ class RBPDF
322
330
  @dpi = 72.0
323
331
  @newpagegroup ||= []
324
332
  @pagegroups ||= {}
333
+ @currpagegroup ||= nil
325
334
  @visibility ||= 'all'
326
335
  @cell_height_ratio = @@k_cell_height_ratio
327
336
  @viewer_preferences ||= {}
@@ -387,6 +396,7 @@ class RBPDF
387
396
  @num_columns ||= 0
388
397
  @current_column ||= 0
389
398
  @column_start_page ||= 0
399
+ @cur_orientation ||= nil
390
400
 
391
401
  # Text rendering mode:
392
402
  # 0 = Fill text;
@@ -433,6 +443,7 @@ class RBPDF
433
443
  @diffs ||= []
434
444
  @images ||= {}
435
445
  @links ||= []
446
+ @html_anchor ||= nil
436
447
  @html_anchors ||= {}
437
448
  @html_anchor_links ||= {}
438
449
  @gradients ||= []
@@ -449,6 +460,11 @@ class RBPDF
449
460
  @fill_color ||= '0 g'
450
461
  @text_color ||= '0 g'
451
462
  @color_flag ||= false
463
+ @title ||= nil
464
+ @author ||= nil
465
+ @subject ||= nil
466
+ @keywords ||= nil
467
+ @creator ||= nil
452
468
 
453
469
  # encryption values
454
470
  @encrypted ||= false
@@ -532,6 +548,7 @@ class RBPDF
532
548
  @annot_obj_id ||= @annots_start_obj_id
533
549
  @curr_annot_obj_id ||= @annots_start_obj_id
534
550
  @apxo_obj_id ||= @apxo_start_obj_id
551
+ @objcopy ||= nil
535
552
  end
536
553
 
537
554
  #
@@ -1494,9 +1511,9 @@ class RBPDF
1494
1511
  # [@since 1.0]
1495
1512
  #
1496
1513
  def Error(msg)
1497
- destroy(true)
1514
+ #destroy(true)
1498
1515
  #Fatal error
1499
- raise ("RBPDF error: #{msg}")
1516
+ raise "RBPDF error: #{msg}"
1500
1517
  end
1501
1518
  alias_method :error, :Error
1502
1519
 
@@ -2674,21 +2691,23 @@ class RBPDF
2674
2691
  end
2675
2692
  end
2676
2693
 
2694
+ fontname = family.gsub(' ', '') + style.downcase
2695
+
2677
2696
  # search and include font file
2678
2697
  if empty_string(fontfile)
2679
2698
  # build a standard filenames for specified font
2680
- fontfile1 = family.gsub(' ', '') + style.downcase + '.rb'
2699
+ fontfile1 = fontname + '.rb'
2681
2700
  fontfile2 = family.gsub(' ', '') + '.rb'
2682
2701
  # search files on various directories
2683
- if (fontdir != false) and File.exists?(fontdir + fontfile1)
2702
+ if (fontdir != false) and File.exist?(fontdir + fontfile1)
2684
2703
  fontfile = fontdir + fontfile1
2685
2704
  fontname = fontfile1
2686
2705
  elsif fontfile = getfontpath(fontfile1)
2687
2706
  fontname = fontfile1
2688
- elsif File.exists?(fontfile1)
2707
+ elsif File.exist?(fontfile1)
2689
2708
  fontfile = fontfile1
2690
2709
  fontname = fontfile1
2691
- elsif (fontdir != false) and File.exists?(fontdir + fontfile2)
2710
+ elsif (fontdir != false) and File.exist?(fontdir + fontfile2)
2692
2711
  fontfile = fontdir + fontfile2
2693
2712
  fontname = fontfile2
2694
2713
  elsif fontfile = getfontpath(fontfile2)
@@ -2700,13 +2719,13 @@ class RBPDF
2700
2719
  end
2701
2720
 
2702
2721
  # include font file
2703
- if File.exists?(fontfile)
2722
+ if File.exist?(fontfile)
2704
2723
  require(fontfile)
2705
2724
  else
2706
2725
  Error('Could not include font definition file: ' + family + '')
2707
2726
  end
2708
2727
 
2709
- font_desc = RBPDFFontDescriptor.font(fontname)
2728
+ font_desc = RBPDFFontDescriptor.font(fontname).dup
2710
2729
  if font_desc[:desc].nil?
2711
2730
  desc = {}
2712
2731
  else
@@ -2745,7 +2764,7 @@ class RBPDF
2745
2764
  if font_desc[:type] == 'cidfont0'
2746
2765
  # register CID font (all styles at once)
2747
2766
  styles = {'' => '', 'B' => ',Bold', 'I' => ',Italic', 'BI' => ',BoldItalic'}
2748
- sname = font_desc[:name] + styles[bistyle]
2767
+ font_desc[:name] = font_desc[:name] + styles[bistyle]
2749
2768
  # artificial bold
2750
2769
  if bistyle.index('B') != nil
2751
2770
  if desc['StemV']
@@ -3725,7 +3744,7 @@ class RBPDF
3725
3744
  if (@color_flag)
3726
3745
  s<<' Q';
3727
3746
  end
3728
- if link && ((link.is_a?(String) and !link.empty?) or (link.is_a?(Fixnum) and link != 0)) # Fixnum is PDF file Page No.
3747
+ if link && ((link.is_a?(String) and !link.empty?) or (link.is_a?(Integer) and link != 0)) # Integer is PDF file Page No.
3729
3748
  Link(xdx, y + ((h - @font_size) / 2.0), width, @font_size, link, ns)
3730
3749
  end
3731
3750
  end
@@ -5017,7 +5036,7 @@ class RBPDF
5017
5036
  return info['i']
5018
5037
  end
5019
5038
  xkimg = ximg * @k
5020
- 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']))
5039
+ 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']))
5021
5040
 
5022
5041
  if border != 0
5023
5042
  bx = x
@@ -5104,22 +5123,6 @@ class RBPDF
5104
5123
  end
5105
5124
  protected :imageToPNG
5106
5125
 
5107
- def image_alpha_mask(file)
5108
- img = Magick::ImageList.new(file)
5109
-
5110
- img2 = img.separate(Magick::OpacityChannel)
5111
- img = img2.negate(true)
5112
-
5113
- #use a temporary file....
5114
- tmpFile = Tempfile.new(['msk_', '.png'], @@k_path_cache)
5115
- tmpFile.binmode
5116
- tmpFile.print img.to_blob
5117
- tmpFile
5118
- ensure
5119
- tmpFile.close unless tmpFile.nil?
5120
- end
5121
- protected :image_alpha_mask
5122
-
5123
5126
  #
5124
5127
  # Extract info from a PNG file
5125
5128
  # [@access protected]
@@ -5236,6 +5239,7 @@ class RBPDF
5236
5239
  ensure
5237
5240
  tmpFile.close unless tmpFile.nil?
5238
5241
  end
5242
+ protected :image_alpha_mask
5239
5243
 
5240
5244
  #
5241
5245
  # Extract info from a PNG image with alpha channel using the GD library.
@@ -5586,7 +5590,7 @@ class RBPDF
5586
5590
  end
5587
5591
  self.instance_variables.each { |val|
5588
5592
  if destroyall or ((val != '@internal_encoding') and (val != '@state') and (val != '@bufferlen') and (val != '@buffer') and (val != '@diskcache') and (val != '@sign') and (val != '@signature_data') and (val != '@signature_max_length') and (val != '@byterange_string'))
5589
- if (!preserve_objcopy or (val.to_s != '@objcopy')) and @val
5593
+ if (!preserve_objcopy or (val.to_s != '@objcopy')) and !val.nil?
5590
5594
  eval("#{val} = nil")
5591
5595
  end
5592
5596
  end
@@ -5620,13 +5624,13 @@ protected
5620
5624
  # Is it in the @@k_path_fonts?
5621
5625
  if @@k_path_fonts
5622
5626
  fpath = File.join @@k_path_fonts, file
5623
- if File.exists?(fpath)
5627
+ if File.exist?(fpath)
5624
5628
  return fpath
5625
5629
  end
5626
5630
  end
5627
5631
  # Is it in this plugin's font folder?
5628
5632
  fpath = File.join File.dirname(__FILE__), 'fonts', file
5629
- if File.exists?(fpath)
5633
+ if File.exist?(fpath)
5630
5634
  return fpath
5631
5635
  end
5632
5636
  # Could not find it.
@@ -5831,7 +5835,7 @@ protected
5831
5835
  #Page content
5832
5836
  p=(@compress) ? Zlib::Deflate.deflate(temppage) : temppage
5833
5837
  newobj();
5834
- out('<<' + filter +' /Length ' + p.length.to_s + '>> ' + getstream(p) + ' endobj')
5838
+ out('<<' + filter + ' /Length ' + p.length.to_s + '>> ' + getstream(p) + ' endobj')
5835
5839
  if @diskcache
5836
5840
  # remove temporary files
5837
5841
  File.delete(@pages[n].path)
@@ -6819,7 +6823,7 @@ protected
6819
6823
  font << [numTables].pack('n') # numTables
6820
6824
  entrySelector = (Math.log(numTables) / Math.log(2.0)).floor
6821
6825
 
6822
- searchRange = 2 **entrySelector * 16
6826
+ searchRange = 2 ** entrySelector * 16
6823
6827
  rangeShift = numTables * 16 - searchRange
6824
6828
  font << [searchRange].pack('n') # searchRange
6825
6829
  font << [entrySelector].pack('n') # entrySelector
@@ -7201,10 +7205,10 @@ protected
7201
7205
  # search and get ctg font file to embedd
7202
7206
  fontfile = ''
7203
7207
  # search files on various directories
7204
- if (fontdir != false) and File.exists?(fontdir + ctgfile)
7208
+ if (fontdir != false) and File.exist?(fontdir + ctgfile)
7205
7209
  fontfile = fontdir + ctgfile
7206
7210
  elsif fontfile = getfontpath(ctgfile)
7207
- elsif File.exists?(ctgfile)
7211
+ elsif File.exist?(ctgfile)
7208
7212
  fontfile = ctgfile
7209
7213
  end
7210
7214
 
@@ -9280,7 +9284,7 @@ public
9280
9284
  Circle(x0, y0, r, 0, 360, circle_style, circle_outLine_style, circle_fill_color)
9281
9285
  end
9282
9286
  p = []
9283
- 0.upto(ns -1) do |i|
9287
+ 0.upto(ns - 1) do |i|
9284
9288
  a = angle + i * 360 / ns
9285
9289
  a_rad = a * ::Math::PI / 180 # deg2rad
9286
9290
  p.push x0 + (r * ::Math.sin(a_rad))
@@ -9328,7 +9332,7 @@ public
9328
9332
  end
9329
9333
  p2 = []
9330
9334
  visited = []
9331
- 0.upto(nv -1) do |i|
9335
+ 0.upto(nv - 1) do |i|
9332
9336
  a = angle + i * 360 / nv
9333
9337
  a_rad = a * ::Math::PI / 180 # deg2rad
9334
9338
  p2.push x0 + r * ::Math.sin(a_rad)
@@ -11030,7 +11034,7 @@ protected
11030
11034
  end
11031
11035
  end
11032
11036
  when ':' # pseudo-class or pseudo-element
11033
- if attrib{1} == ':' # pseudo-element
11037
+ if attrib[1] == ':' # pseudo-element
11034
11038
  # pseudo-elements are not supported!
11035
11039
  # (::first-line, ::first-letter, ::before, ::after)
11036
11040
  else # pseudo-class
@@ -11161,7 +11165,7 @@ protected
11161
11165
  uri_path = uri_path.join(path)
11162
11166
  }
11163
11167
  cssdata = ''
11164
- next unless File.exists?(uri_path)
11168
+ next unless File.exist?(uri_path)
11165
11169
 
11166
11170
  open(uri_path) do |f|
11167
11171
  cssdata << f.read
@@ -11207,7 +11211,6 @@ protected
11207
11211
  html.gsub!(/<(table|tr|td|th|blockquote|dd|div|dt|h1|h2|h3|h4|h5|h6|br|hr|li|ol|ul|p)([^\>]*)>[\n\r\t]+/, '<\\1\\2>')
11208
11212
  html.gsub!(/@(\r\n|\r)@/, "\n")
11209
11213
  html.gsub!(/[\t\0\x0B]/, " ")
11210
- html.gsub!(/\\/, "\\\\\\")
11211
11214
 
11212
11215
  offset = 0
11213
11216
  while (offset < html.length) and ((pos = html.index('</pre>', offset)) != nil)
@@ -11710,7 +11713,7 @@ protected
11710
11713
  # text
11711
11714
  dom[key]['tag'] = false
11712
11715
  dom[key]['block'] = false
11713
- dom[key]['value'] = unhtmlentities(element).gsub(/\\\\/, "\\")
11716
+ dom[key]['value'] = unhtmlentities(element)
11714
11717
  dom[key]['parent'] = level[-1]
11715
11718
  end
11716
11719
  elkey += 1
@@ -11724,13 +11727,35 @@ protected
11724
11727
  # [@param string :attrname] image file name
11725
11728
  #
11726
11729
  def get_image_filename( attrname )
11727
- testscrtype = URI.parse(attrname)
11730
+ attrname_escape = File.join(File.dirname(attrname), ERB::Util.url_encode(File.basename(attrname)))
11731
+ testscrtype = URI.parse(attrname_escape)
11728
11732
  if testscrtype.query.nil? or testscrtype.query.empty?
11729
11733
  # convert URL to server path
11730
11734
  attrname = attrname.gsub(@@k_path_url, @@k_path_main)
11731
11735
  end
11732
11736
  end
11733
11737
 
11738
+ #
11739
+ # Get image file from remote URL
11740
+ # [@param string :image_uri] image URI path
11741
+ #
11742
+ def get_image_file(image_uri)
11743
+ image_uri = File.join(File.dirname(image_uri), ERB::Util.url_encode(File.basename(image_uri)))
11744
+ uri = URI.parse(image_uri)
11745
+ extname = File.extname(uri.path)
11746
+
11747
+ #use a temporary file....
11748
+ tmpFile = Tempfile.new(['tmp_', extname], @@k_path_cache)
11749
+ tmpFile.binmode
11750
+ Net::HTTP.start(uri.host, uri.port) do |http|
11751
+ res = http.get(uri.path)
11752
+ tmpFile.print res.body
11753
+ end
11754
+ tmpFile
11755
+ ensure
11756
+ tmpFile.close unless tmpFile.nil?
11757
+ end
11758
+
11734
11759
  #
11735
11760
  # Convert to accessible url path
11736
11761
  # [@param string :url] url path
@@ -13117,9 +13142,10 @@ public
13117
13142
  # tag['attribute']['src'] = Rails.root.join('public') + tag['attribute']['src']
13118
13143
  # end
13119
13144
  #end
13120
- img_name = tag['attribute']['src']
13121
13145
  ### T.B.D ### TCPDF 5.0.000 ###
13122
- # tag['attribute']['src'] = CGI.escape(tag['attribute']['src'])
13146
+ tag['attribute']['src'].gsub!(/%([0-9a-fA-F]{2})/){$1.hex.chr}
13147
+
13148
+ img_name = tag['attribute']['src']
13123
13149
  type = getImageFileType(tag['attribute']['src'])
13124
13150
  tag['attribute']['src'] = get_image_filename(tag['attribute']['src'])
13125
13151
  if tag['width'].nil?
@@ -13194,16 +13220,25 @@ public
13194
13220
  SetRightMargin(@r_margin + @c_margin)
13195
13221
 
13196
13222
  begin
13223
+ if tag['attribute']['src'] =~ /^http/
13224
+ tmpFile = get_image_file(tag['attribute']['src'])
13225
+ img_file = tmpFile.path
13226
+ else
13227
+ img_file = tag['attribute']['src']
13228
+ end
13197
13229
  # if (type == 'eps') or (type == 'ai')
13198
- # ImageEps(tag['attribute']['src'], xpos, @y, iw, ih, imglink, true, align, '', border, true)
13230
+ # ImageEps(img_file, xpos, @y, iw, ih, imglink, true, align, '', border, true)
13199
13231
  # elsif type == 'svg'
13200
- # ImageSVG(tag['attribute']['src'], xpos, @y, iw, ih, imglink, align, '', border, true)
13232
+ # ImageSVG(img_file, xpos, @y, iw, ih, imglink, align, '', border, true)
13201
13233
  # else
13202
- result_img = Image(tag['attribute']['src'], xpos, @y, iw, ih, '', imglink, align, false, 300, '', false, false, border, false, false, true)
13234
+ result_img = Image(img_file, xpos, @y, iw, ih, '', imglink, align, false, 300, '', false, false, border, false, false, true)
13203
13235
  # end
13204
13236
  rescue => err
13205
13237
  logger.error "pdf: Image: error: #{err.message}"
13206
13238
  result_img = false
13239
+ ensure
13240
+ # remove temp files
13241
+ tmpFile.delete unless tmpFile.nil?
13207
13242
  end
13208
13243
 
13209
13244
  if result_img or ih != 0