Page 1 of 1

help finding AltChunkProperties

PostPosted: Thu Sep 29, 2011 8:10 am
by dan.percival
Just getting started with docx4j and finding it very useful. I've run into a hitch with HTML altChunks, though: I'd like the styling of the main document to flow through instead of using the style of the HTML (which is defaulting to Times New Roman etc.).

I've found a post describing an AltChunkProperties found within the Open XML SDK that can be configured to make the altChunk import match the document style:

Code: Select all
altChunk = new AltChunk();
AltChunkProperties altChunkProperties = new AltChunkProperties();
altChunkProperties.MatchSource = new MatchSource() { Val = new OnOffValue(false)};
altChunk.AppendChild<AltChunkProperties>(altChunkProperties);

(from http://social.msdn.microsoft.com/Forums ... f5f94ca3fa)

I've looked for a corresponding class in the docx4j API, but haven't found it yet. I'd be grateful if someone could point me in the right direction.

Thanks!

Re: help finding AltChunkProperties

PostPosted: Thu Sep 29, 2011 9:06 am
by jason
Try something like:

Code: Select all
        CTAltChunk ac = Context.getWmlObjectFactory().createCTAltChunk();
       
        CTAltChunkPr acpr = Context.getWmlObjectFactory().createCTAltChunkPr();
        acpr.setMatchSrc(new BooleanDefaultTrue() );
       
        ac.setAltChunkPr(acpr);

Re: help finding AltChunkProperties

PostPosted: Thu Sep 29, 2011 10:37 am
by dan.percival
Thanks for the pointer, jason. That's exactly what I was looking for. I can generate wordML that looks like what I would expect it to:
Code: Select all
<w:altChunk r:id="rId3">
  <w:altChunkPr>
    <w:matchSrc w:val="true"/>
  </w:altChunkPr>
</w:altChunk>
<w:altChunk r:id="rId4">
  <w:altChunkPr>
    <w:matchSrc w:val="false"/>
  </w:altChunkPr>
</w:altChunk>

...but both the HTML documents specified with rId3 and rId4, when opened in Word, show up in Times New Roman instead of using the document paragraph style. Any thoughts on what I might be missing?

Re: help finding AltChunkProperties

PostPosted: Sat Aug 11, 2012 12:10 am
by Empirica
Hi there, has there been a solution for this ?

We are facing the same problem as dan.percival did.

Re: help finding AltChunkProperties

PostPosted: Sat Aug 11, 2012 9:09 am
by jason
This is a question which relates to the Open XML file format and Word's implementation of it, rather than docx4j per se.

So I'd suggest you post it on http://social.msdn.microsoft.com/Forums ... ma/threads