Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text aligment JUSTIFY not wokring in Microsoft Word #2628

Open
2 tasks
FaheemKGNINFOTECH opened this issue Jul 2, 2024 · 0 comments
Open
2 tasks

Text aligment JUSTIFY not wokring in Microsoft Word #2628

FaheemKGNINFOTECH opened this issue Jul 2, 2024 · 0 comments

Comments

@FaheemKGNINFOTECH
Copy link

Describe the bug and add attachments

when setting

$paragraphStyle = [
'alignment' => Jc::JUSTIFY,
'spaceBefore' => Converter::pointToTwip(5),
'spaceAfter' => Converter::pointToTwip(5),
'lineHeight' => 1.0
];

alignment JUSTIFY then the word file is not opening
phpword

Expected behavior

It should open in microsoft word also like WPS

Steps to reproduce

use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\SimpleType\Jc;
use PhpOffice\PhpWord\Shared\Converter;

$phpWord = new PhpWord();

        $fontStyle = ['name' => 'Arial', 'size' => 12];
        $paragraphStyle = [
            'alignment' => Jc::JUSTIFY,
            'spaceBefore' => Converter::pointToTwip(5),
            'spaceAfter' => Converter::pointToTwip(5),
            'lineHeight' => 1.0
        ];

        $section = $phpWord->addSection();
        $section->addText('Remember, exact vertical centering in PHPWord may vary depending on the content size and the overall cell height set.	Remember, exact vertical centering in PHPWord may vary depending on the content size and the overall cell height set.	', $fontStyle, $paragraphStyle);


        // Force download
        header("Content-Description: File Transfer");
        header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
        header('Content-Disposition: attachment; filename="text_justify.docx"');

        header('Cache-Control: max-age=0');
        header('Pragma: public');

        // Create a temporary file in the system's temporary directory
        $tempFile = tempnam(sys_get_temp_dir(), 'phpword');
        $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
        $objWriter->save($tempFile);

        // Download the file
        readfile($tempFile);
        unlink($tempFile); // Delete the temp file after downloading
        exit;

PHPWord version(s) where the bug happened

"phpoffice/phpword": "^1.2",

PHP version(s) where the bug happened

"php": "^8.1",

Priority

  • I want to crowdfund the bug fix (with @algora-io) and fund a community developer.
  • I want to pay the bug fix and fund a maintainer for that. (Contact @Progi1984)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants