Categories > OpenTBS with DOCX >

Corruption with ope=changepic

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Sarah
Date: 2015-03-07
Time: 01:03

Corruption with ope=changepic

I have a pretty simple template in which I am switching out .png images. There is one in the document that is just transparent, and when the document merges, I use ope=changepic to switch in another image that is visible. My image Alt Text looks like:

[onshow.data.signer.signature;ope=changepic;tagpos=inside]

I have tried onload and onshow. When I take this tag out (so I'm not swapping pictures at all), the document merges perfectly. When I merge with a picture swap, I get a corrupt docx. Word does repair it successfully (and my swapped image is correct once it repairs), but doesn't give me any information about the source of the corruption. I can also repair the file manually by changing the extension to .zip and going into word/media and deleting the original .png (image1.png). Once this file is gone, Word no longer complains about the file being corrupt and the document looks perfect.

I updated to the newest OpenTBS and TBS but it did not help.

* Debug command: OPENTBS_DEBUG_XML_SHOW
* OpenTBS version: 1.9.4
* TinyButStrong version: 3.9.0
* PHP version: 5.5.9-1ubuntu4.6YES
* Opened document: templates/commercial-invoice.docx
* Activated features for document type: openxml/docx
* Deleted files in the archive: none
* Added files in the archive:
  - word/media/opentbs_added_1.png
* Modified files in the archive:
  - word/header1.xml
  - word/header2.xml
  - word/footer1.xml
  - word/footer2.xml
  - docProps/core.xml
  - word/document.xml
  - word/_rels/document.xml.rels

I've been beating my head on a wall trying to figure out why this simple template isn't working (and I could have sworn it was working for a while...), but I am not making progress. Any thoughts what could be causing it or how I can find out more about the problem? Should the original image1.png still be present in the archive after the merge or is it supposed to be deleting and my permissions are screwing something up?

As always, love OpenTBS.

Thanks for reading.
By: Skrol29
Date: 2015-03-07
Time: 23:04

Re: Corruption with ope=changepic

Hi Sarah,

I cannot reproduce your bug.
Can you send to me an extract of your code+template that reproduce it ?

By: Sarah
Date: 2015-03-09
Time: 16:15

Re: Corruption with ope=changepic

Predictably, I started putting together a sample to send you and it worked... so I compared to my code and added an exit() after my Show and it no longer comes up corrupted (which should have been super obvious but for some reason only became a problem when I changed the picture?) I don't know why it worked fine when I didn't use ope=changepic and broke when I did if it was just about extra code at the end, especially since when I actually examined the source of document.xml it was valid XML and nothing looked odd about it. And espcially since all I had to do was delete the original picture from the media folder to repair it... I'm sorry to have bothered you with it though.

I will email you the sample that does break though, in case you want to have a look. I'm using Word 2010, if that makes any difference.
By: Skrol29
Date: 2015-03-09
Time: 23:42

Re: Corruption with ope=changepic


Thank for your message and for the example to reproduce the problem.

The problem of extra content after the end of the script is known.
There is a very good practice to avoid it : do no close the last PHP tag at the end of the script : "?>"
This tag is optional. If you omit it there is no problem of extra line or extra contents.



By: Sarah
Date: 2015-03-10
Time: 00:05

Re: Corruption with ope=changepic

I know it is not required, the example I sent was a very simplified version... I assumed, I think, that Show(Download) would exit on its own since no content can be added after or the document would corrupt, I just didn't think it through. I thought it odd that the extra content from the page does not show up in the document.xml but still somehow corrupts it, and that removing the image1.png would fix it... Just one of those things I guess. Thank you for your time.