spipu / html2pdf

OFFICIAL PROJECT | HTML to PDF converter written in PHP
http://html2pdf.fr/en/default
Open Software License 3.0
1.68k stars 751 forks source link

The html tag [figure] is not known by Html2Pdf. You can create it and push it on the Html2Pdf GitHub project. #764

Open djoo opened 1 year ago

djoo commented 1 year ago

Hey guys,

I have a script who generate PDF from WordPress post. From the last version WordPress include

tags for nothing... Exemple :

<figure class="wp-block-table"><table><tbody><tr><td>Text.</td></tr><tr><td>Diagnose: Text</td></tr></tbody></table></figure>

When i try to PDF this, i have the error : The html tag [figure] is not known by Html2Pdf. You can create it and push it on the Html2Pdf GitHub project.

So i try to figure out. Creating a tag in /vendor/spipu/html2pdf/src/Tag/Html/Figure.php

<?php
/**
 * Html2Pdf Library - Tag class
 *
 * HTML => PDF converter
 * distributed under the OSL-3.0 License
 *
 * @package   Html2pdf
 * @author    Laurent MINGUET <webmaster@html2pdf.fr>
 * @copyright 2017 Laurent MINGUET
 */
namespace Spipu\Html2Pdf\Tag\Html;

/**
 * Tag Figure
 */
class Figure extends Span
{
    /**
     * @inheritdoc
     */
    public function getName()
    {
        return 'figure';
    }
}

But it still doesn't work. What can i do to make it works ? (I don't want to change the behaviour of Wordpress.)

Thanks

fredmatrack commented 1 year ago

I added this

protected function initTags() { return array( new Html\Address(), new Html\B(), new Html\Big(), new Html\Bookmark(), new Html\Cite(), new Html\Del(), new Html\Em(), new Html\Font(), new Html\I(), new Html\Ins(), new Html\Label(), new Html\S(), new Html\Samp(), new Html\Small(), new Html\Span(), new Html\Strong(), new Html\Sub(), new Html\Sup(), new Html\U(), new Html\Figure(), ); }

To the src/Extension/Core/HtmlExtension.php file