Forum


Replies: 3   Views: 439
Tabs in replacevariablebyhtml
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by tangamampilia  · 16-08-2023 - 18:57

Hi,

I'm trying to achieve using tabs with this method. 

 

$docs = new CreateDocxFromTemplate('document.docx');

$docs->createParagraphStyle('tabs', [
        'color' => '999999',
        'border' => 'single',
        'borderLeft' => 'double',
        'borderColor' => '990000',
        'borderRightColor' => '000099',
        'borderWidth' => 12,
        'borderTopWidth' => 24,
        'indentLeft' => 920,
        'tabPositions' => [[
                'type' => 'left'
        ]]
]);

$tabs = '<span class="tabs"></span><span class="tabs"></span>Hello World';
$docs->replaceVariableByHTML('TABS', 'inline', $tabs)

It's doesn't looks like any style is being applied. This is the right implementation?

Thanks!

Posted by admin  · 16-08-2023 - 22:02

Hello,

What version of phpdocx are you using? Your username doesn't have any license tied, please send to contact[at]phpdocx.com the username or email of the user that purchased the license you are using.

Custom paragraph styles can be applied to paragraph contents, not to span contents. In the case of replacements, custom paragraph styles are block contents, so inline replacements can't be done to apply them. Please check the following sample included in the package: embedHTML/sample_4.php that illustrates how to use custom styles applied to HTML contents.

To add tabs when transforming HTML, a Premium license with HTML Extended is recommended:

$html = '<span>My text content&amp;#9;with a tab.</span>';
$docx->embedHTML($html, array('useHTMLExtended' => true));
$html = '<span>My text content&amp;#9;with a tab.</span>';
$docx->replaceVariableByHTML('TABS', 'inline', $html, array('useHTMLExtended' => true));

Regards.

Posted by tangamampilia  · 17-08-2023 - 15:39

Hi, the username tied to my license is ---removed---. I'll try with your suggestion.

Posted by uncontested  · 18-08-2023 - 20:07

Thanks for the solution, it worked!