Pregunta

I have been using OpenTBS for modifying DOCX files. When I am merging my DB info with the DOCX file it always leave blank data for any info in my DB that is missing.

Here is an image of my 'source' document on the left and my merge on the right. Merging document issue in OpenTBS

How do I go about removing the extra line breaks?

Here is the code producing this merge if it assists you

    public function mergeFields($template_file, Array $user, Array $lead){
        require_once('components/tbs_class_php5.php');
        require_once('components/tbs_plugin_opentbs.php');

        //Instantiate new class
        $tbs = new clsTinyButStrong;
        $tbs->NoErr = true;
        $tbs->Plugin(TBS_INSTALL,OPENTBS_PLUGIN);

        $tbs->LoadTemplate($template_file);
        $tbs->MergeBlock('l',$lead);
        $tbs->MergeBlock('u',$user);
        $mergeFile = dirname(Yii::app()->basePath).DIRECTORY_SEPARATOR.'components/merge.docx';

        $tbs->Show(OPENTBS_FILE, $mergeFile);
        chmod($mergeFile,0755);
        return $mergeFile;
    }
¿Fue útil?

Solución

Whichever field you think is not compulsory or can have a null value, include a magnet tag like following :

[l.co;magnet=w:p]

Here magnet is a conditional which deletes the tag if the value is null or empty. It is having the value "w:p" because DOCX's XML file contains all the new values in a tag like :-

<w:p>...</w:p>

So it will delete the tag and whitespace will be removed.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top