Plugin Contributor
Ewout
(@pomegranate)
Hello Ponco,
Unfortunately the PDF engine does not support the first-line pseudo-element. If you really want to format the first line differently and not use the separate fields to build the address, you could try and use php to process the address, for example like this:
add_filter( 'wpo_wcpdf_billing_address', 'wpo_wcpdf_wrap_first_address_line', 10, 1 );
add_filter( 'wpo_wcpdf_shipping_address', 'wpo_wcpdf_wrap_first_address_line', 10, 1 );
function wpo_wcpdf_wrap_first_address_line( $address ) {
// first add the opening element
$address = '<span class="first-line">' . $address;
// find position of the first line break
$line_break_pos = strpos( $address, '<br/>' );
if ($line_break_pos !== false) {
// replace first line break with closing tag and line break
$address = substr_replace($address,'</span><br/>',$line_break_pos,strlen('<br/>'));
}
return $address;
}
This will add a span to the first line with the first-line class which you can then use to format it.
Note that, depending on the specifics of the address format, this could mean that the sometimes this is the company being formatted, and otherwise it will be the first name. It is really only the first line. You could try a similar approach to format the second line, but you’ll have to figure that out yourself.
Good luck!
Ewout
p.s. you might want to check the formatting of the ‘
‘ part, it could be different on your server (‘
‘ or ‘
‘), this worked for me though!
Plugin Contributor
Ewout
(@pomegranate)
whoops, that ps got a little bit messed up! should be:
you might want to check the formatting of the <br/> part, it could be different on your server (<br> or <br />). This worked for me though!
Plugin Contributor
Ewout
(@pomegranate)
@ponco85 – did this work for you? Let me know if you have any questions!
Hi
sry for l8 reply. I was little bit off-line 😉
working perfect!