使用PHP从页面提取html代码以推断一些图像

使用PHP从页面提取html代码以推断一些图像,php,html,wordpress,domdocument,Php,Html,Wordpress,Domdocument,我必须从我的WP站点的产品详细信息页面创建一个PDF文档,并从该页面提取所有html代码以推断img和表标记。 我安装了一个插件来从页面创建PDF文档,但是没有插入imagese和表:只有文本被插入到文档中 这个插件是woocommercePrintProduct,我编辑了它的代码,将图像插入到PDF文档中。应修改的功能如下: div class="descrizione" style="margin:0 30px;"> <div class="colonna

我必须从我的WP站点的产品详细信息页面创建一个PDF文档,并从该页面提取所有html代码以推断img和表标记。 我安装了一个插件来从页面创建PDF文档,但是没有插入imagese和表:只有文本被插入到文档中

这个插件是woocommercePrintProduct,我编辑了它的代码,将图像插入到PDF文档中。应修改的功能如下:

div class="descrizione" style="margin:0 30px;">
            <div class="colonnaSx" style="float:left;width:350px;margin-right:30px">
                <div class="pacchettino">
                    <?php if( get_field('descrizione_prod') ): ?>
                        <h3>DESCRIPTION</h3>
                        <p><?php the_field('descrizione_prod'); ?></p>
                    <?php endif; ?>
                </div>

                <div class="pacchettino">
                    <?php if( get_field('forma') ): ?>
                        <h3>SHAPE</h3>
                        <p><?php the_field('forma'); ?></p>
                    <?php endif; ?>
                </div>

                <div class="pacchettino">
                    <?php if( get_field('posa') ): ?>
                        <h3>INSTALLATION</h3>
                        <p><?php the_field('posa'); ?></p>
                    <?php endif; ?>
                </div>

                <div class="pacchettino">
                    <?php if( get_field('conduttore') ): ?>
                        <h3>CONDUCTOR</h3>
                        <p><?php the_field('conduttore'); ?></p>
                    <?php endif; ?>
                </div>

                <div class="pacchettino">
                    <?php if( get_field('isolante') ): ?>
                        <h3>INSULATION</h3>
                        <p><?php the_field('isolante'); ?></p>
                    <?php endif; ?>
                </div>

                <div class="pacchettino">
                    <?php if( get_field('guaina') ): ?>
                        <h3>SHEAT</h3>
                        <p><?php the_field('guaina'); ?></p>
                    <?php endif; ?>
                </div>

                <div class="pacchettino">
                    <?php if( get_field('sforzo_massimo_di_tiro') ): ?>
                        <h3>MAX MECHANICAL STRESS</h3>
                        <p><?php the_field('sforzo_massimo_di_tiro'); ?></p>
                    <?php endif; ?>
                </div>

                <div class="pacchettino">
                    <?php if( get_field('guainetta') ): ?>
                        <h3>INTERNAL SHEATH</h3>
                        <p><?php the_field('guainetta'); ?></p>
                    <?php endif; ?>
                </div>
            </div>

            <div class="colonnaDx" style="float:right;width:350px;">
                <div class="pacchettino">
                    <?php if( get_field('marchiatura') ): ?>
                        <h3>MARCHIATURA</h3>
                        <p><?php the_field('marchiatura'); ?></p>
                    <?php endif; ?>
                </div>

                <div class="pacchettino">
                    <?php if( get_field('colore') ): ?>
                        <h3>COLORE</h3>
                        <p><?php the_field('colore'); ?></p>
                    <?php endif; ?>
                </div>

                <div class="pacchettino">
                    <?php if( get_field('tensione_di_esercizio') ): ?>
                        <h3>TENSIONE DI ESERCIZIO</h3>
                        <p><?php the_field('tensione_di_esercizio'); ?></p>
                    <?php endif; ?>
                </div>

        <?php /*
        <table class="description">
            <?php
            $description = wpautop($this->data->description);
            $description = preg_replace("/\[[^\]]+\]/", '', $description);
            $description = explode('<p>', $description);
            foreach ($description as $value) {
            ?>
                <tr>
                    <td  style="padding-bottom: 20px;">
                        <?php echo $value ?>
                    </td>
                </tr>
                <?php
            }
            ?>

        </table>

        */
        ?>

        <div class="description"  style="margin:0 30px;">
            <?php
                $description = wpautop($this->data->description);
                $description = preg_replace("/\[[^\]]+\]/", '', $description);
                $description = explode('<p>', $description); 
                foreach ($description as $value) {
            ?>

                <div class="pacchettino" style="padding-bottom: 20px;margin:0 30px;">
                    <?php 
                        echo $value 
                    ?>
                </div> 

            <?php
            }
            ?>

        </div>


        <?php

        return ob_get_clean();

    }
div class=“descripione”style=“margin:0 30px;”>
描述

形状

装置

导体

绝缘

展示

最大机械应力

内护套

马尔基亚图拉

彩色

张紧器

*/ ?>
有很多更简单的解决方案

我推荐WKHTMLtoPDF,它是开源的,没有浏览器,没有应用程序,只有命令行,非常简单。

如何使用: 从上面的链接安装后 打开命令提示符 输入

wkhtmltopdf {website} {filename to save as}
例如:

wkhtmltopdf http://google.com google.pdf
用户手册:


还有许多其他的程序,甚至在线工具,可以完全免费完成你的要求,许多甚至像上面一样是开源的。当你可以免费获得圆柱体时,没有必要剃一个方形的钉子来装一个圆孔。

插件的名称是什么?插件是woocommercePrintProduct,我已经编辑了它的代码以在PDF文档中插入图像