Page 1 of 1

Textbox not working

PostPosted: Mon Dec 30, 2013 11:42 pm
by gex
Hi,

we are using a lot of textboxes to get text into various positions at our docx files. The problem seems to be that these are not recognized during PDF output. I receive the following error:

30.12.2013 13:43:08 *WARN * AbstractConversionContext: NOT IMPLEMENTED: support for w:pict; without v:imagedata (AbstractMessageWriter.java, line 46)

When browsing the document.xml, I found that word seems to implement textboxes as follows:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
<w:pict>
  <v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe">
    <v:stroke joinstyle="miter"/>
    <v:path gradientshapeok="t" o:connecttype="rect"/>
  </v:shapetype>
  <v:shape id="_x0000_s1026" type="#_x0000_t202" style="position:absolute;margin-left:90.55pt;margin-top:9.3pt;width:180.6pt;height:172.35pt;z-index:251660288;mso-width-percent:400;mso-height-percent:200;mso-width-percent:400;mso-height-percent:200;mso-width-relative:margin;mso-height-relative:margin" stroked="f">
    <v:textbox style="mso-fit-shape-to-text:t">
      <w:txbxContent>
        <w:p w:rsidR="008659C7" w:rsidRPr="008659C7" w:rsidRDefault="008659C7">
          <w:pPr>
            <w:rPr>
              <w:sz w:val="72"/>
              <w:szCs w:val="72"/>
            </w:rPr>
          </w:pPr>
          <w:proofErr w:type="spellStart"/>
          <w:r w:rsidRPr="008659C7">
            <w:rPr>
              <w:sz w:val="72"/>
              <w:szCs w:val="72"/>
            </w:rPr>
            <w:t>Textbox</w:t>
          </w:r>
          <w:proofErr w:type="spellEnd"/>
          <w:r w:rsidRPr="008659C7">
            <w:rPr>
              <w:sz w:val="72"/>
              <w:szCs w:val="72"/>
            </w:rPr>
            <w:t xml:space="preserve"> Test</w:t>
          </w:r>
        </w:p>
      </w:txbxContent>
    </v:textbox>
  </v:shape>
</w:pict>
 
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


So it is true, it is a w:pict without v:imagedata. Is this to be implemented soon? Or can I implement it myself? I am quite proficient in java, but not in docx or pdf processing.

Re: Textbox not working

PostPosted: Tue Dec 31, 2013 9:52 am
by jason
Support for textboxes in PDF output is a highly desirable feature. Tracked at https://github.com/plutext/docx4j/issues/64

The reason we haven't implemented it so far is that FOP (the XSL FO processor our PDF output uses by default) doesn't support floats: http://xmlgraphics.apache.org/fop/compl ... ject-float

If v:textbox to fo:float were to be implemented in docx4j, you could then use an XSL FO processor with support for fo:float (ie one of the commercial implementations eg http://xep.xattic.com/xep/testsuite/usecases/float.pdf ) to create your PDF output.

The slight challenge in implementing v:textbox to fo:float is parsing @style, at least for position (given by margin-left and margin-top) and size (width;height).

In the meantime, I suggest you try LibreOffice 4.1.4. If that can render your docx satisfactorily, you can use it to convert to PDF, and you can do this server side, driving it using JODConverter.

Re: Textbox not working

PostPosted: Thu Feb 13, 2014 10:27 am
by jason
docx4j 3.0.1 is now out. It includes incomplete support for text boxes in PDF output.

It turns out there are lots of text box options in WordML, a subset of which we support.

FO supports some text box options better than others, and different FO renderers have different capabilities (eg whether or not there support fo:float).

Feedback welcome.