Forum


Replies: 6   Views: 2499
Span tag removes space after
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 queejie  · 25-01-2019 - 14:51

When generating a Word doc from HTML, this:

<span class="italic">some</span> text

and this:

<em>some</em> text

The result is 'sometext' in the first case and 'sometext' in the second.  In both cases, the space between some and text is removed.

These are the options used:

    public $docxParseOptions = [
        'downloadImages'           => TRUE,
        'generateCustomListStyles' => TRUE,
        'parseDivsAsPs'            => FALSE,
        'parseFloats'              => FALSE,
        'removeLineBreaks'         => TRUE,
        'strictWordStyles'         => FALSE,
        'addDefaultStyles'         => TRUE,
    ];

Is one of these settings wrong, a setting missing, or is this a bug? Thank you.

Posted by admin  · 25-01-2019 - 15:48

Hello,

We have tested both HTML and they work correctly, the space between the paragraphs is not removed.

Please do the following tests:

· Don't use the removeLineBreaks option, you can set is as false as well.

· Wrap the HTML using a parent such a paragraph:

$html .= '<p><em>some</em> text</p>';
$docx->embedHTML($html);

Regards.

Posted by queejie  · 29-01-2019 - 18:44

I ran just that snippet to create a document and it worked.  The problem remains, however.  Here is an actual example from a larger document:

<p><img class="pull-left" src="-valid-url-" alt=""> For each question, you will choose the best answer from the four possible choices. You should answer every question, even if you are just guessing. If you get stuck on a question, you can place a mark in the margin of the test booklet and return to it later. If you decide to change your answer on the answer sheet, make sure you erase the first answer choice completely; failure to do so may result in a wrong answer being identified by the scanner.</p>
<p>During the test, you may write in the test booklet or on scrap paper provided specifically for the test administration. Any paper you use <strong>WILL</strong> be collected by the Proctor prior to your departure from the testing session.</p>

The 'Any paper you use <strong>WILL</strong> be' portion comes out in Word as:

Any paper you use  WILLbe

There is an extra space before and no space after it. If I test just those paragraphs alone as a document, it works fine.  In the larger context of the full document it doesn't work.  I even tried setting a style for strong to have 0 margin before and 10px after, without success.

I wish I could paste the .html and .docx files here to demonstrate.

 

Posted by admin  · 29-01-2019 - 19:19

Hello,

phpdocx users create DOCX with hundreds (and thousands) of pages from huge HTML contents without issues, so this isn't the problem.

Just to test it, we have run the following script:

$html = '
<p><img class="pull-left" src="-valid-url-" alt=""> For each question, you will choose the best answer from the four possible choices. You should answer every question, even if you are just guessing. If you get stuck on a question, you can place a mark in the margin of the test booklet and return to it later. If you decide to change your answer on the answer sheet, make sure you erase the first answer choice completely; failure to do so may result in a wrong answer being identified by the scanner.</p>
<p>During the test, you may write in the test booklet or on scrap paper provided specifically for the test administration. Any paper you use <strong>WILL</strong> be collected by the Proctor prior to your departure from the testing session.</p>
';
$docx->embedHTML($html);

And the output is correct opening it with MS Word 2007 to MS Word 2016 and LibreOffice 6.

Please reply to the topic with the following information:

  • The program used to open the DOCX
  • php version
  • OS
  • if you are using LAMP, WAMP, MAMP or any other preset installation, and its version

You can also send to contact[at]phpdocx.com the HTML and DOCX output and we'll check it.

Regards.

Posted by queejie  · 29-01-2019 - 20:33

Thank you very much.  I replied via email with attachments of HTML and docx files that do and don't work.  It may have something to do with merge of multiple section documents into a single doc.

Posted by queejie  · 29-01-2019 - 21:23

Deleted by queejie · 29-01-2019 - 21:25

Posted by queejie  · 29-01-2019 - 21:49

One more clue that might be helpful.  I am using tidy::repairString() on incoming HTML, and that generates classes like 'tidy-1'.  It may be that those classes are affecting this issue.  I am going to try and make sure they are integrated into the final doc.