Project

General

Profile

Defect #10688 » tcpdf.rb_table_with_html_fix_r9852.diff

Jun NAITOH, 2012-06-17 14:35

View differences:

lib/plugins/rfpdf/lib/tcpdf.rb (working copy)
283 283
		@state ||= 0
284 284
  	@tableborder ||= 0
285 285
  	@tdbegin ||= false
286
	@tdtext ||= ''
286 287
  	@tdwidth ||= 0
287 288
  	@tdheight ||= 0
288 289
  	@tdalign ||= "L"
......
3510 3511
				
3511 3512
      else
3512 3513
        #Text
3513
				if (@href)
3514
				if (@tdbegin)
3514 3515
					element.gsub!(/[\t\r\n\f]/, "");
3516
					@tdtext << element.gsub(/&nbsp;/, " ");
3517
				elsif (@href)
3518
					element.gsub!(/[\t\r\n\f]/, "");
3515 3519
					addHtmlLink(@href, element, fill);
3516
				elsif (@tdbegin)
3517
					element.gsub!(/[\t\r\n\f]/, "");
3518
					element.gsub!(/&nbsp;/, " ");
3519
					base_page = @page;
3520
					base_x = @x;
3521
					base_y = @y;
3522

  
3523
					MultiCell(@tdwidth, @tdheight, unhtmlentities(element.strip), @tableborder, @tdalign, @tdfill, 1);
3524
					tr_end = @t_cells[@table_id][@tr_id][@td_id]['j1'] + 1;
3525
					if @max_td_page[tr_end].nil?  or (@max_td_page[tr_end] < @page)
3526
						@max_td_page[tr_end] = @page
3527
						@max_td_y[tr_end] = @y
3528
					elsif (@max_td_page[tr_end] == @page)
3529
						@max_td_y[tr_end] = @y if @max_td_y[tr_end].nil? or (@max_td_y[tr_end] < @y) 
3530
					end
3531

  
3532
					@page = base_page;
3533
					@x = base_x + @tdwidth;
3534
					@y = base_y;
3535 3520
				elsif (@pre_state == true and element.length > 0)
3536 3521
					Write(@lasth, unhtmlentities(element), '', fill);
3537 3522
				elsif (element.strip.length > 0)
......
3825 3810
				@x += 5;	
3826 3811

  
3827 3812
			when 'table'
3813
				Ln();
3828 3814
				if @default_table_columns < @max_table_columns[@table_id]
3829 3815
					@table_columns = @max_table_columns[@table_id];
3830 3816
				else
......
3921 3907
				
3922 3908
			when 'img'
3923 3909
				if (!attrs['src'].nil?)
3910
					# Don't generates image inside table tag
3911
					if (@tdbegin)
3912
						@tdtext << attrs['src'];
3913
						return
3914
					end
3924 3915
					# Only generates image include a pdf if RMagick is avalaible
3925 3916
					unless Object.const_defined?(:Magick)
3926 3917
						Write(@lasth, attrs['src'], '', fill);
......
4079 4070
				Ln();
4080 4071

  
4081 4072
			when 'td','th'
4073
				base_page = @page;
4074
				base_x = @x;
4075
				base_y = @y;
4076

  
4077
				MultiCell(@tdwidth, @tdheight, unhtmlentities(@tdtext.strip), @tableborder, @tdalign, @tdfill, 1);
4078
				tr_end = @t_cells[@table_id][@tr_id][@td_id]['j1'] + 1;
4079
				if @max_td_page[tr_end].nil?  or (@max_td_page[tr_end] < @page)
4080
					@max_td_page[tr_end] = @page
4081
					@max_td_y[tr_end] = @y
4082
				elsif (@max_td_page[tr_end] == @page)
4083
					@max_td_y[tr_end] = @y if @max_td_y[tr_end].nil? or (@max_td_y[tr_end] < @y) 
4084
				end
4085

  
4086
				@page = base_page;
4087
				@x = base_x + @tdwidth;
4088
				@y = base_y;
4089
				@tdtext = '';
4082 4090
				@tdbegin = false;
4083 4091
				@tdwidth = 0;
4084 4092
				@tdheight = 0;
......
4126 4134
				@l_margin -= 5;
4127 4135
				@r_margin -= 5;
4128 4136
				@tableborder=0;
4129
				Ln();
4130 4137
				@table_id += 1;
4131 4138
				
4132 4139
			when 'strong'
(4-4/7)