Forum


Replies: 1   Views: 1164
How to remove lines created in word?
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 tjchen  · 22-12-2020 - 04:37

Lines generated with "addShape" can be removed by "removeWordContent", but lines generated in Word (simply cut and paste the line generated with addShape) can not be removed.

Please see the sample docx.

https://drive.google.com/file/d/1yaU6SEbsIDsdBxQam-pIXTfXz3ya8nN3/view?usp=sharing

Red line is generated with "addShape", and blue line is copied from red line in Word.

Strangely, Google drive can not recognize red line.

Is it possible to remove blue line programmatically, like

$docx->removeWordContent(['type' => 'shape']);

Thanks.

 

 

Posted by admin  · 22-12-2020 - 07:02

Hello,

addShape adds w:pict tags that are supported by MS Word, LibreOffice and other DOCX readers:

<w:p>
  <w:r>
    <w:pict>
      <v:line from="10,10" strokecolor="#ff0000" strokeweight="1pt" style="position:absolute;margin-left:20pt;z-index:67407;" to="150,150"/>
    </w:pict>
  </w:r>
</w:p>

But your MS Word program has generated other code for the blue line using <w:drawing> tags.  As these tags are not directly supported by removeWordContent setting a secific type, you'd need to use a custom query to remove them based on w:p/w:r//w:drawing XPath. In the package (DOCXPath folder) you can find samples about using custom queries with DOCXPath.

About Google Drive compatiblity, please note that it doesn't support all OOXML standard, so some contents may not appear.

Regards.