Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4627442
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:34:05+00:00 2026-05-22T03:34:05+00:00

1) convert <table style=width: 700px; height: 300px; background-color: #ff0000; border=0> to <table width=700 height=300

  • 0

1) convert

<table style="width: 700px; height: 300px; background-color: #ff0000;" border="0">

to

<table width="700" height="300" bgcolor="#ff0000" border="0">

2) convert

<table style="width: 700px; background-color: #ff0000;" border="0">

to

<table width="700" bgcolor="#ff0000" border="0">

I’m using Joomla 1.5.x where in content client can add table or nested tables. Tinymce using inline styles for table dimensions, background properties. But when we try to generate pdf from front end inline styles for table are ignored. Joomla is using TCPDF to generate I’ve updated the version but same problem. When I’ve converted the css properties into html attributes, it is generating the table in formated way. So thought to replace all inline styles for table, td, th to html attributes. Tried with many thread from this website but unable to make use of them as I’m poor at regular expressions.

Please any help me in doing so.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:34:06+00:00Added an answer on May 22, 2026 at 3:34 am

    I think you can use PHP DOM for this.

    1) Use DOMElement::getAttribute() to get the value of attribute style=

    2) Use $split = explode(";", $style) to separate those css values

    3) With each entry $i of $split, $attributes = explode(":", $split[$i]), in get attribute’s name and its value.

    4) Now you got $attributes holding 2 values: attribute and value of that attribute.

    5) Use DOMElement::setAttribute() to add those values of $attributes.

    So, put everything into codes:

    $dom = new DOMDocument();
    
    $dom->loadHTML($html);
    
    $atrvalue= $dom->getAttribute("style");
    
    $split = explode(";", $atrvalue);
    
    for ($i=0; $i<=count($split); $i++) {
        $attribute = explode(":", $split[$i]);
        $node = $doc->createElement("table");
        $newnode = $doc->appendChild($node);
        $newnode->setAttribute($attribute[0], $attribute[1]);
    }
    

    This way doesn’t involve regex 🙂 But you need to modify it in order to fit your context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(TextReader reader, StyleSheet style) to convert an html table into a pdf
In WYSIWYG editor, I have <TABLE style=WIDTH: 162pt; BORDER-COLLAPSE: collapse border=0 cellSpacing=0 cellPadding=0 width=216>
Using PHP, I can convert MySQL data or static table data to csv, Excel,
Suppose I have the HTML code as below <table width=600 border=0 cellpadding=0 cellspacing=0 align=center
Is there any guidelines to convert Table design to Div design keeping same cross
What is the best optimized way to convert table base design to table less
I am given a task to convert a huge table to custom XML file.
I want to convert the mysql database table contents to an Excel(.xls) or comma
LINQ to SQL allows table mappings to automatically convert back and forth to Enums
I'm trying to convert an Excel document into a table in SQL 2005. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.