Categories > OpenTBS with DOCX >

"No error detail available" - Very corrupt .docx

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Sarah
Date: 2012-12-19
Time: 20:07

"No error detail available" - Very corrupt .docx

At least this new one sounds better than the "Catastrophic failure" I was getting yesterday ;)

I am transitioning my existing OpenTBS application from using groups acting as a canvas in Compatibility Mode in Word 2007 to <drawing>s in a non-Compatibility Mode Word 2010 .docx.

I am running into trouble moving from changing the style attribute of my <v:imagedata> to the <a:ext> element of the <pic:pic> in the <drawing>. Here is what I have:

<a:xfrm>
    <a:off x="0" y="0"/>
    <a:ext cx="[LineItem.image.EMUs.width;]" cy="[LineItem.image.EMUs.height;]" />
</a:xfrm>

The value of LineItem.image.EMUs.width is int(7429500) and height is int(6057900) when I var_dump them. However, when I try to merge them as above, the TBS debug output is:

<a:ext 7429500th;]" 6057900ht;]" />

Interestingly, if I add zeroes before the merge tags like this:

<a:xfrm>
    <a:off x="0" y="0"/>
    <a:ext cx="0000[LineItem.image.EMUs.width;]" cy="0000[LineItem.image.EMUs.height;]" />
</a:xfrm>

My output changes to:

<a:ext cx="7429500th;]" cy="6057900ht;]" />

The output I am looking for is:

<a:ext cx="7429500" cy="6057900" />

I have also tried this using the att=a:ext#cx like so:

<a:ext cx="0" cy="0"/>
[LineItem.image.EMUs.width;att=a:ext#cx]
[LineItem.image.EMUs.height;att=a:ext#cy]

And get the following:

<a:ext 7429500x="0" 6057900y="0"/>

...Which is really confusing.

I have done a lot with these tags in the older style of xml and never had this issue. What am I doing wrong?

Thank you for reading and for any help you can offer!
By: Skrol29
Date: 2012-12-20
Time: 01:31

Re: "No error detail available" - Very corrupt .docx

Hi Sarah,

The shift probably comes from another TBS field, such as a field for merging the picture. Do you have such a field?
Can't you adjust the picture size using parameter "adjust" ?
By: Sarah
Date: 2012-12-20
Time: 18:20

Re: "No error detail available" - Very corrupt .docx

Yes, this is in the middle of a <pic:pic> block with a [LineItem.image.fullname;ope=changepic;default=current;noerr] that changes the picture out.

Thank you for telling me about adjust. I tried using it alone, with samewidth and with a percentage. The only real change I saw was with the percentage (adjust=30%), but my image was still stretched out and it just cut off at about 30% of the height (more like a crop than a scale).

I think I need more control over the image size than just proportional scaling because I basically have about 20 images that might be put into the document (various accessories to the LineItem). These images are all different sizes and I was using a single image in the template with a block so it will make multiple images when there are multiple accessories (or none if there are no accessories). I set the height and width to be equal to the size of the image (determined with GD).

I am using an object to hold the information about the image I want to switch in, so when TBS runs, I use a block. Is it necessary for me to have a second merge block call to insert the size and position of the image before the ope=changepic is run? My array of objects (accessories) holds Images like this:

["image"]=>
        object(Image)#10 (9) {
          ["width"]=>
          int(56)
          ["height"]=>
          int(103)
          ["EMUs"]=>
          array(2) {
            ["width"]=>
            int(7429500)
            ["height"]=>
            int(6057900)
          }
          ["fullname"]=>
          string(43) "templates/images/item1.png"
        }

To merge these, I use [LineItem_sub2.image.fullname;ope=changepic;default=current;noerr]

Thank you for your response!
By: Skrol29
Date: 2012-12-21
Time: 00:28

Re: "No error detail available" - Very corrupt .docx

It is hard-coded that OpenTBS is operating a shift of TBS fields is some inner XML of the picture during the merging of pictures.

But there is a workaround: you just have to use 2 mergings instead of one.

Let the parts:
<a:ext cx="0000[LineItem.image.EMUs.width;]" cy="0000[LineItem.image.EMUs.height;]" />
and:
$TBS->MergeBlock('LineItem', $data)

But replace:
[LineItem.image.fullname;ope=changepic;default=current;noerr]
with:
[onshow.data.[LineItem.$].image.fullname;ope=changepic;default=current;noerr]

This could be optimize, but it should work.
By: Sarah
Date: 2012-12-22
Time: 00:50

Re: "No error detail available" - Very corrupt .docx

Thank you for the new snippet to try. I used the [onshow.data.[LineItem.$].image.fullname;ope=changepic;default=current;noerr] and it worked great once I changed my array keys to not use dots (probably a bad idea in the first place!).  The issue I am encountering now is how to achieve the same effect with LineItem_sub2, which loops through the accessory items. I tried using [onshow.data.[LineItem_sub2.$].image.fullname;ope=changepic;default=current;noerr] but got the TBS error that '$' is not part of the LineItem_sub2 array. Am I just messing up my syntax here? I'm not totally clear on how _subs interact with $.

I really appreciate you taking the time to help me out with this.
By: Sarah
Date: 2012-12-26
Time: 20:17

Re: "No error detail available" - Very corrupt .docx

I am also running into other problems with my subblock (sub2) now as I am referencing it in a couple of (non-adjacent) blocks in the template.

However, the two blocks are not adjacent in my template and TBS smashes them together when I have a block= reference for both places. This causes the document to fail to open because of mismatched tags. Is it possible to have one subblock print in two areas of the template?

Thanks again for reading.
By: Skrol29
Date: 2012-12-28
Time: 02:39

Re: "No error detail available" - Very corrupt .docx

Hi Sarah,

> got the TBS error that '$' is not part of the LineItem_sub2

Make sure you have TBS 3.8.0.
This message is probably probably because the block "LineItem_sub2" is not defined; i.e. it has no "block=" parameter.

>However, the two blocks are not adjacent in my template and TBS smashes them
> together when I have a block= reference for both places.

This is the normal behavior for TBS. They are several logical reasons for this.
Nevertheless, you can use the "p1" tip as described here:
  http://www.tinybutstrong.com/manual.php#php_mergeblock_mergesevera
By: Sarah
Date: 2012-12-31
Time: 20:08

Re: "No error detail available" - Very corrupt .docx

Ok, I believe I am understanding this better now (Not the p1 part, that still just seems like magic). I do have 3.8.0, and you were right about the lack of block= reference. 'p1' also worked like a charm. I am encountering a new problem, however. I will post a new topic since the subject no longer applies to my issue.

Thank you very much for your help! I am continually surprised by the little solutions OpenTBS offers that you always find after I have scoured the manual and feel there is nothing left I haven't read.
By: Bridget Brown
Date: 2013-03-09
Time: 10:18

Re: "No error detail available" - Very corrupt .docx

If corrupted .docx is the issue, then you may repair it by using Open and Repair of MS Office. You may also try to open the .docx file in OpenOffice-org Writer. If both these don't work or fail to open the file, then you may go for third=party recovery software. I recommend you to use SysInfoTools MS Word Docx Recovery or you may check its free demo version before buying it. It will fix your corrupted .docx file. I have it a couple of times.
http://www.sysinfotools.com/recovery/ms-word-docx-recovery.html
Regards.
By: Skrol29
Date: 2013-03-11
Time: 22:53

Re: "No error detail available" - Very corrupt .docx

Hi Bridget

This is not relevant: if the template is not corrupted, then so must be the merged result. OpenTBS is reasonable of the corruption.