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

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
2 tasks
ICALLYOU opened this issue Nov 28, 2024 · 2 comments
Labels
Bug Report Status: Waiting for feedback Question has been asked, waiting for response from PR author

Comments

@ICALLYOU
Copy link

ICALLYOU commented Nov 28, 2024

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)
@Progi1984
Copy link
Member

@ICALLYOU Thank you for your issue. Could you send me a Word file for reproducing the issue ? Thanks

@Progi1984 Progi1984 added the Status: Waiting for feedback Question has been asked, waiting for response from PR author label Feb 3, 2025
@vgavrilovikj
Copy link

Any progress on this? I have the same issue.. the generated PDF does not match the Word style..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Report Status: Waiting for feedback Question has been asked, waiting for response from PR author
Development

No branches or pull requests

3 participants