简体   繁体   English

添加图像时phpWord文件增长问题

[英]phpWord file growth issue when adding images

Ok, here's the scenario. 好的,这是场景。 I need to generate about 200 MS Word documents based off of data collected and stored in my database. 我需要根据收集和存储在数据库中的数据生成大约200个MS Word文档。 Generating the word docs with or without photos is a user option. 用户可以选择生成带有或不带有照片的docs一词。 After Word doc generation I then want to create a zip file of all the files generated. 在生成Word doc之后,我想要创建所有已生成文件的zip文件。 The zip part is done, the word file generation for the most part is done. zip部分已完成,大部分单词文件生成已完成。

When the user chooses to generate the reports without the photos, the site queries the database and returns about 200 records for the report, and then with a foreach loop I run the PHPWord coding to generate and write the files to a temp folder and then after the foreach loop I'm running code to zip them all up and then delete the temp files. 当用户选择生成不带照片的报告时,该站点将查询数据库并返回该报告的约200条记录,然后使用foreach循环运行PHPWord编码以生成文件并将其写入temp文件夹,然后foreach循环我正在运行代码以将它们全部压缩,然后删除临时文件。 Works great. 效果很好。 BUT, when the option to generate the reports WITH photos is selected, it starts generating the Word docs, but the file sizes increase every time a file is created. 但是,当选择了生成带有照片的报告的选项时,它将开始生成Word文档,但是每次创建文件时文件大小都会增加。 First file is 70k, the second file is 140k, the third is 210k and so on, where each file should only be 70k each. 第一个文件为70k,第二个文件为140k,第三个文件为210k,依此类推,其中每个文件每个应仅为70k。 The only difference in the two operations in the inclusion of the addImage commands with the table cells like so: 这两个操作的唯一区别在于表单元格包含addImage命令,如下所示:

$table->addCell()->addImage('photos/thumb_image.jpg, $imageStyle);

Help please! 请帮助!

从0.10.0开始可用的循环之间使用Media::resetElements()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM