##// END OF EJS Templates
PDF: import Chinese rfpdf patch for textilized PDF (#69)....
Toshi MARUYAMA -
r6013:e9cdaf0d4bc7
parent child
Show More
@@ -142,15 +142,20 module PDF_Chinese
142 return l*@font_size/1000
142 return l*@font_size/1000
143 end
143 end
144
144
145 def MultiCell(w,h,txt,border=0,align='L',fill=0)
145 def MultiCell(w,h,txt,border=0,align='L',fill=0,ln=1)
146 if(@current_font['type']=='Type0')
146 if(@current_font['type']=='Type0')
147 MBMultiCell(w,h,txt,border,align,fill)
147 MBMultiCell(w,h,txt,border,align,fill,ln)
148 else
148 else
149 super(w,h,txt,border,align,fill)
149 super(w,h,txt,border,align,fill,ln)
150 end
150 end
151 end
151 end
152
152
153 def MBMultiCell(w,h,txt,border=0,align='L',fill=0)
153 def MBMultiCell(w,h,txt,border=0,align='L',fill=0,ln=1)
154
155 # save current position
156 prevx = @x;
157 prevy = @y;
158
154 #Multi-byte version of MultiCell()
159 #Multi-byte version of MultiCell()
155 cw=@current_font['cw']
160 cw=@current_font['cw']
156 if(w==0)
161 if(w==0)
@@ -233,18 +238,30 module PDF_Chinese
233 b+='B'
238 b+='B'
234 end
239 end
235 Cell(w,h,s[j,i-j],b,2,align,fill)
240 Cell(w,h,s[j,i-j],b,2,align,fill)
236 @x=@l_margin
241
242 # move cursor to specified position
243 if (ln == 1)
244 # go to the beginning of the next line
245 @x=@l_margin
246 elsif (ln == 0)
247 # go to the top-right of the cell
248 @y = prevy;
249 @x = prevx + w;
250 elsif (ln == 2)
251 # go to the bottom-left of the cell
252 @x = prevx;
253 end
237 end
254 end
238
255
239 def Write(h,txt,link='')
256 def Write(h,txt,link='',fill=0)
240 if(@current_font['type']=='Type0')
257 if(@current_font['type']=='Type0')
241 MBWrite(h,txt,link)
258 MBWrite(h,txt,link,fill)
242 else
259 else
243 super(h,txt,link)
260 super(h,txt,link,fill)
244 end
261 end
245 end
262 end
246
263
247 def MBWrite(h,txt,link)
264 def MBWrite(h,txt,link,fill=0)
248 #Multi-byte version of Write()
265 #Multi-byte version of Write()
249 cw=@current_font['cw']
266 cw=@current_font['cw']
250 w=@w-@r_margin-@x
267 w=@w-@r_margin-@x
@@ -263,7 +280,7 module PDF_Chinese
263 ascii=(c<128)
280 ascii=(c<128)
264 if(c.chr=="\n")
281 if(c.chr=="\n")
265 #Explicit line break
282 #Explicit line break
266 Cell(w,h,s[j,i-j],0,2,'',0,link)
283 Cell(w,h,s[j,i-j],0,2,'',fill,link)
267 i+=1
284 i+=1
268 sep=-1
285 sep=-1
269 j=i
286 j=i
@@ -296,9 +313,9 module PDF_Chinese
296 if(i==j)
313 if(i==j)
297 i+=ascii ? 1 : 2
314 i+=ascii ? 1 : 2
298 end
315 end
299 Cell(w,h,s[j,i-j],0,2,'',0,link)
316 Cell(w,h,s[j,i-j],0,2,'',fill,link)
300 else
317 else
301 Cell(w,h,s[j,sep-j],0,2,'',0,link)
318 Cell(w,h,s[j,sep-j],0,2,'',fill,link)
302 i=(s[sep].chr==' ') ? sep+1 : sep
319 i=(s[sep].chr==' ') ? sep+1 : sep
303 end
320 end
304 sep=-1
321 sep=-1
@@ -316,7 +333,7 module PDF_Chinese
316 end
333 end
317 #Last chunk
334 #Last chunk
318 if(i!=j)
335 if(i!=j)
319 Cell(l/1000*@font_size,h,s[j,i-j],0,0,'',0,link)
336 Cell(l*@font_size/1000.0,h,s[j,i-j],0,0,'',fill,link)
320 end
337 end
321 end
338 end
322
339
General Comments 0
You need to be logged in to leave comments. Login now