0

I think that paragraph elements by definition creates a new line but I need to insert elements as the first element of a page not moving down existing elements.

Is there another element I can use instead of paragraph? I think that only tables and paragraphs are available and I understand that tables contains paragraphs so they don't work for my purpose.

Or maybe exists any property I can set to avoid the new paragraph moving the other elements?

I tried keepNext and keepLines but is not what I'm looking for.

Paco Abato
  • 3,920
  • 4
  • 31
  • 54
  • I did a bit of a hack: I'm taking the first paragraph and adding to it my new elements. It works for me but maybe there are a more generic solution. – Paco Abato Nov 27 '14 at 11:42
  • Rather than adding a paragraph, which will be a new block element, you may want to consider something like adding a `Run` to an existing paragraph? – Ben Nov 27 '14 at 12:44
  • That is what I'm doing (see my previous comment). But it looks like something strange to do it that way. – Paco Abato Nov 27 '14 at 13:41
  • Maybe you want a text box? If you can work out what you want in Word/OpenXML, then docx4j code can follow. – JasonPlutext Nov 28 '14 at 11:10
  • @PacoAbato Why is that strange? – Ben Nov 28 '14 at 13:03
  • @Ben It looks like kind of antisemanthic to me (inserting graphical elements into existent and no related paragraphs). But, hey, it works. – Paco Abato Nov 28 '14 at 20:45
  • @JasonPlutext I'm inserting floating ellipses over the document's content. I insert them as the first element of the page to absolutly position them (that's why I don't want a new line at the top of the document). I think that text boxes must be inserted into a paragraph so I would be facing the same problem. – Paco Abato Nov 28 '14 at 20:53

1 Answers1

0

You can absolutely position an ellipse, without it being in the first paragraph on the page.

In Word, on your ellipse, right click and choose "More layout options". On the position tab, eg 1" below page.

This creates something like:

        <w:r>
            <w:pict>
                <v:oval strokecolor="#243f60 [1604]" strokeweight="2pt" 
style="position:absolute;margin-left:41.25pt;margin-top:1in;
width:207.35pt;height:1in;z-index:251659264;visibility:visible;mso-wrap-style:square;mso-width-percent:0;mso-wrap-distance-left:9pt;mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;mso-wrap-distance-bottom:0;mso-position-horizontal:absolute;mso-position-horizontal-relative:text;mso-position-vertical:absolute;mso-position-vertical-relative:page;mso-width-percent:0;mso-width-relative:margin;v-text-anchor:middle" id="Oval 1" o:spid="_x0000_s1026">
                        <w10:wrap anchory="page"/>
                    </v:oval>
                </w:pict>
            </w:r>

If for some reason you want to add a new first paragraph, you could make the paragraph have a small font, with no space before or after. r:Pr/r:vanish causes the ellipse to vanish, so don't try that!

JasonPlutext
  • 15,352
  • 4
  • 44
  • 84