PHP + PDF Line Break -


i have below code in magento store adds customers address invoice pdf's. lines of address long address labels added $value = wordwrap($text, 10, "
\n"); line thinking create new line. however, doesn't seem work in pdf docs , end funny symbol i'd line be. know how can new line?

p.s - php knowledge basic.

if (!$order->getisvirtual()) { if ($this->y < 250) { $page = $this->newpage(); }  $this->_setfontregular($page, 6); $page->drawtext('ship to:', 75, 222 , 'utf-8');  $shippingaddress = $this->_formataddress($order->getshippingaddress()->format('pdf'));  $line = 185; $this->_setfontregular($page, 12);  $num_lines = count($shippingaddress); $curr_line = 0; foreach ($shippingaddress $value) { $curr_line += 1;  if ($curr_line < $num_lines) { if ($value!=='') { $value = wordwrap($value, 20, "\n"); $page->drawtext(strip_tags(ltrim($value)), 75, $line, 'utf-8'); $line -=14; } } } }  

using wordwrap start, won't way there. want do separate call $page->drawtext each line.

so example this.

$textchunk = wordwrap($value, 20, "\n"); foreach(explode("\n", $textchunk) $textline){   if ($textline!=='') {     $page->drawtext(strip_tags(ltrim($textline)), 75, $line, 'utf-8');     $line -=14;   } } 

and aware depending on have on pdf, can quite complex. example, if user can enter in text want section, need make sure text doesn't overrun section's text. mean if have block of text above block of text, need push down y-coordinates of lower block number of lines created wordwrap() increases


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -