Forum


Replies: 3   Views: 1120
Top border missing from image
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by RDI  · 01-11-2021 - 22:44

When using addImage with a border the top border is getting cut-off / not rendered.

If I export to PDF the top border is still missing, even in the PDF.

Going into "Format Picture" in Word and changing anything (like moving Transparency from 0% to 1%) causes the top border to then get rendered.

So it seems like the code getting generated by phpdocx is missing something or is incorrect in some way that gets fixed by Word when the image is edited. The problem is the Word doc I'm generating has dozens of images that all have this problem.

Here is simple code that demonstrates the problem.

<?php

require_once $_SERVER["DOCUMENT_ROOT"] . '/includes/phpdocx-12/classes/CreateDocx.php';

$docx = new CreateDocx();

$docx->modifyPageLayout(
        'letter',
        array(
                'marginLeft' => round(1440 * 0.75),
                'marginRight' => round(1440 * 0.75)
        )
);

$img = 'testDocx.jpg';

$width = 600;
$height = 600;

$docx->addText(
                'Heading Text',
                array(
                        'fontSize' => 10,
                        'textAlign' => 'left',
                        'bold' => true,
                        'caps' => true,
                        'keepLines' => true,
                        'keepNext' => true
                )
        );

$imgOptions = array(
        'src' => $img,
        'spacingTop' => 0,
        'spacingBottom' => 0,
        'spacingLeft' => 0,
        'spacingRight' => 0,
        'textWrap' => 0,
        'imageAlign' => 'center',
        'width' => $width,
        'height' => $height,
        'borderColor' => 'AAAAAA',
        'borderStyle' => 'solid',
        'borderWidth' => 1,
);
$docx->addImage($imgOptions);        

$docx->createDocxAndDownload('test');

?>

The image is an 1800 x 1800 screen capture of a map (I didn't see a way to attach it) that gets scaled to 600 x 600.

Thanks