Forum


Replies: 4   Views: 3672
Replace image on cover page
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 Squad internet  · 25-02-2014 - 07:04

Hi guys,



I'm trying to replace an image that resides on the cover page. I have (more or less) the following code.



$this->_document=new createDocx($pathToMyTemplate, $pathToSpecificTempDir);

......

$this->_document->addTemplateImage('_MYIMAGE_', $imagePath);



Now I get the following error:



Warning: DOMDocument::loadXML(): Empty string supplied as input in /var/www/Core/0.1/Includes/phpdocx/classes/CreateTemplate.inc on line 1149



It looks like that self::$_document is not set.

Now in the examples you use a different call to add a template file, but that call makes it impossible to target a specific tmp dir, something that is important in this case.



 



Any hints?



 



 


Posted by jorgelj  · 25-02-2014 - 09:47

Hello,



You can set a custom temp dir in the config/phpdocx_config.ini file instead of the createDocx method. Are you using the latest version of PHPDocx?



Regards.


Posted by Squad internet  · 25-02-2014 - 13:22

Tnx for your reply,

Yes I'm using the latest version, I just downloaded it yesterday.

The problem is however the same as in 3.1

I can NOT use the same tmp dir for every user that is using this tool.

I have to deal with very strict ACL and base_dir restriction that I can not break.

The same problem exists with the logger, its impossible to set the tmpdir at runtime,.. and so my logger is broken. I simply modified the logger code to return insteadt of writing a log message,.. its dirty but for now the issue is fixed.



Could you maybe give me a hint where the config file is beeing read and in what property(s) it is stored?

I know what the tmp dir should be before calling any method with phpDocx, the only thing I need is "somehow" override the tmpDir property "somewhere" ;)



I really don't mind writing some setter method myself, I allready extended the CreateDocx class, and logic tells me I should find this magic property somewhere in this class... but "where"?



I hope you can help me out here.



 


Posted by Squad internet  · 25-02-2014 - 13:27

Uhm,



I'm actually reading the CreateDocx file right now,.. and there is a setter method available.

The constructor also changed, as it does not accept a tmp dir anymore.



Things changed ;)

I'm gonna do some testing, I'll let you know if it worked.