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 · 0 comments

Comments

@ICALLYOU
Copy link

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant