Skip to content

Using Phpword version 1.3.0 to generate a temporary Word file and then convert the temporary file to a PDF document results in the PDF document having a different format from the Word document, with images being enlarged. How can this be fixed? #2707

Open
@ICALLYOU

Description

@ICALLYOU

Describe the bug and add attachments

Using Phpword version 1.3.0 to generate a temporary Word file and then convert the temporary file to a PDF document results in the PDF document having a different format from the Word document, with images being enlarged. How can this be fixed?

Expected behavior

Using Phpword version 1.3.0 to generate a temporary Word file and then convert the temporary file to a PDF document results in the PDF document having a different format from the Word document, with images being enlarged. How can this be fixed?

Steps to reproduce

   $tempFilePath = '../runtime/tempfile/temp_docx_file'.time("now").'.docx';
        $writer = IOFactory::createWriter($phpWord, 'Word2007');
        $writer->save($tempFilePath);
        //转pdf
        Settings::setPdfRendererPath(base_path('../vendor/tecnickcom/tcpdf'));
        Settings::setPdfRendererName('TCPDF');
        $wordPdf = IOFactory::load($tempFilePath);
        $pdfWriter = IOFactory::createWriter($wordPdf , 'PDF');
        $temp_path = '../runtime/tempfile/temp_pdf_file'.time("now").'.pdf';
        //文件保存
        $pdfWriter->save($temp_path);
        // 读取文件内容为二进制字符串
        $fileContent = file_get_contents($temp_path);
        // 将二进制字符串转换为Base64编码
        $base64Encoded = base64_encode($fileContent);
        //unlink($tempFilePath);
        unlink($temp_path);
        unlink($backendPictureUrl);

PHPWord version(s) where the bug happened

1.3.0

PHP version(s) where the bug happened

7.2

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions