From aba15481c8d6e11c00e4715b233b9c9f2cc0e6d0 Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Sun, 4 May 2014 22:34:37 +0200 Subject: [PATCH] Corrected typo to 'const POSITION_HORIZONTAL_CENTER = 'center';' and added examples to Sample_13 --- samples/Sample_13_Images.php | 31 +++++++++++++++++++++++++++++++ src/PhpWord/Style/Image.php | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php index 78423065..dd5209bf 100644 --- a/samples/Sample_13_Images.php +++ b/samples/Sample_13_Images.php @@ -31,6 +31,37 @@ foreach ($wrappingStyles as $wrappingStyle) { $section->addText($text); } +//Absolute positioning +$section->addTextBreak(3); +$section->addText('Absolute positioning: see top right corner of page'); +$section->addImage( + 'resources/_mars.jpg', + array( + 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), + 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), + 'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE, + 'marginLeft' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(15.5), + 'marginTop' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(1.55) + ) +); + +//Relative positioning +$section->addTextBreak(3); +$section->addText('Relative positioning: Horizontal position center relative to column,'); +$section->addText('Vertical position top relative to line'); +$section->addImage( + 'resources/_mars.jpg', + array( + 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), + 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), + 'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE, + 'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_CENTER, + 'posHorizontalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_COLUMN, + 'posVertical' => \PhpOffice\PhpWord\Style\Image::POSITION_VERTICAL_TOP, + 'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_LINE + ) +); + // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); if (!CLI) { diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php index 4dbfa5f4..9274b0c9 100644 --- a/src/PhpWord/Style/Image.php +++ b/src/PhpWord/Style/Image.php @@ -31,7 +31,7 @@ class Image extends AbstractStyle * @const string */ const POSITION_HORIZONTAL_LEFT = 'left'; - const POSITION_HORIZONTAL_CENTER = 'centered'; + const POSITION_HORIZONTAL_CENTER = 'center'; const POSITION_HORIZONTAL_RIGHT = 'right'; /**