문제

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;
    }
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top