@@ -633,11 +633,18 @@ protected static function parseStyle($attribute, $styles)
633
633
}
634
634
$ styles ['italic ' ] = $ tValue ;
635
635
break ;
636
+ case 'margin ' :
637
+ $ cValue = Converter::cssToTwip ($ cValue );
638
+ $ styles ['spaceBefore ' ] = $ cValue ;
639
+ $ styles ['spaceAfter ' ] = $ cValue ;
640
+ break ;
636
641
case 'margin-top ' :
637
- $ styles ['spaceBefore ' ] = Converter::cssToPoint ($ cValue );
642
+ // BC change: up to ver. 0.17.0 incorrectly converted to points - Converter::cssToPoint($cValue)
643
+ $ styles ['spaceBefore ' ] = Converter::cssToTwip ($ cValue );
638
644
break ;
639
645
case 'margin-bottom ' :
640
- $ styles ['spaceAfter ' ] = Converter::cssToPoint ($ cValue );
646
+ // BC change: up to ver. 0.17.0 incorrectly converted to points - Converter::cssToPoint($cValue)
647
+ $ styles ['spaceAfter ' ] = Converter::cssToTwip ($ cValue );
641
648
break ;
642
649
case 'border-color ' :
643
650
self ::mapBorderColor ($ styles , $ cValue );
@@ -676,7 +683,7 @@ protected static function parseStyle($attribute, $styles)
676
683
}
677
684
// normalization: in HTML 1px means tinest possible line width, so we cannot convert 1px -> 15 twips, coz line'd be bold, we use smallest twip instead
678
685
$ size = strtolower (trim ($ matches [1 ]));
679
- // (!) BC change: up to ver. 0.17.0 Converter was incorrectly converting to points - Converter::cssToPoint($matches[1] )
686
+ // BC change: up to ver. 0.17.0 incorrectly converted to points - Converter::cssToPoint($size )
680
687
$ size = ($ size == '1px ' ) ? 1 : Converter::cssToTwip ($ size );
681
688
// valid variants may be e.g. borderSize, borderTopSize, borderLeftColor, etc ..
682
689
$ styles ["border {$ which }Size " ] = $ size ; // twips
@@ -732,14 +739,14 @@ protected static function parseImage($node, $element)
732
739
case 'float ' :
733
740
if (trim ($ v ) == 'right ' ) {
734
741
$ style ['hPos ' ] = \PhpOffice \PhpWord \Style \Image::POS_RIGHT ;
735
- $ style ['hPosRelTo ' ] = \PhpOffice \PhpWord \Style \Image::POS_RELTO_PAGE ;
742
+ $ style ['hPosRelTo ' ] = \PhpOffice \PhpWord \Style \Image::POS_RELTO_MARGIN ; // inner section area
736
743
$ style ['pos ' ] = \PhpOffice \PhpWord \Style \Image::POS_RELATIVE ;
737
744
$ style ['wrap ' ] = \PhpOffice \PhpWord \Style \Image::WRAP_TIGHT ;
738
745
$ style ['overlap ' ] = true ;
739
746
}
740
747
if (trim ($ v ) == 'left ' ) {
741
748
$ style ['hPos ' ] = \PhpOffice \PhpWord \Style \Image::POS_LEFT ;
742
- $ style ['hPosRelTo ' ] = \PhpOffice \PhpWord \Style \Image::POS_RELTO_PAGE ;
749
+ $ style ['hPosRelTo ' ] = \PhpOffice \PhpWord \Style \Image::POS_RELTO_MARGIN ; // inner section area
743
750
$ style ['pos ' ] = \PhpOffice \PhpWord \Style \Image::POS_RELATIVE ;
744
751
$ style ['wrap ' ] = \PhpOffice \PhpWord \Style \Image::WRAP_TIGHT ;
745
752
$ style ['overlap ' ] = true ;
0 commit comments