thuliobuarque / java2word

Automatically exported from code.google.com/p/java2word
0 stars 0 forks source link

Clarification: How to set the page orientation #15

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Does the API provide an option to change the page orientation for Word 2000?

Original issue reported on code.google.com by udug...@gmail.com on 20 Dec 2010 at 4:59

GoogleCodeExporter commented 8 years ago
Hi Udugani

First of all, Java2word doesn't support W2000 in the current version. Documents 
generated by java2word can only be opened in MS Word 2003 (or older), which 
support the XML standard.

I will have a look at the page orientation and write back in this issue. Good 
one!

thanks

Leonardo

Original comment by leonardo...@gmail.com on 20 Dec 2010 at 10:01

GoogleCodeExporter commented 8 years ago
Take a look at the attached document and tell me if this is orientation 
"Horizontal".

*I am using a Word Viewer in Linux running on Wine so I can't ensure that is 
working.

If this is the result you expect, I tell you how to do.
Java2word doesn't provide native support for page orientation but there is 
always a way around...

cheers

Leonardo

Original comment by leonardo...@gmail.com on 21 Dec 2010 at 9:00

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by leonardo...@gmail.com on 21 Dec 2010 at 9:00

GoogleCodeExporter commented 8 years ago
Yes; exactly this what I was looking for!

Could you please explain how to achieve this

Thanks

Original comment by udug...@gmail.com on 21 Dec 2010 at 4:06

GoogleCodeExporter commented 8 years ago
I will tell you in 8 hours, time when I get home because I am at work and don't 
have the code here but will be easy. 

I will give you the work around code until I add the functionality to the API 
in a proper way ok?

It will be a few lines just before:

 doc.getContent();

I assume that you are already using Java2word library in your system.

I have changed the issue to "Enhancement" so that I will will implement some 
time in the future.

Come back here around 7pm, Melbourne time, Australia.

cheers

Leonardo

Original comment by leonardo...@gmail.com on 21 Dec 2010 at 10:36

GoogleCodeExporter commented 8 years ago
udugani

This is the code that produces the attached word document: 

   @Test
    public void basicFluentTest02() {
        IDocument doc = new Document2004();

//        Heading1222 h1 = (Heading1222) 
Heading1222.with("h222").withStyle().setBold(true).setItalic(true).create();

        ParagraphPiece piece = new ParagraphPiece("Leonardo Correa Courrier");
        piece.getStyle().setFont(ParagraphPieceStyle.Font.COURIER);

        Paragraph p01 = new Paragraph(piece);

        Paragraph p02 = new Paragraph("This is default font");

        doc.addEle(p01);
        doc.addEle(p02);
        doc.addEle(Heading1.with("h3333").create());

        String orientation = "    <w:sectPr wsp:rsidR=\"00F04FB2\" wsp:rsidSect=\"00146B2A\">\n" +
        "      <w:pgSz w:w=\"16834\" w:h=\"11904\" w:orient=\"landscape\"/>\n" +
        "      <w:pgMar w:top=\"1800\" w:right=\"1440\" w:bottom=\"1800\" w:left=\"1440\" w:header=\"708\" w:footer=\"708\" w:gutter=\"0\"/>\n" +
        "      <w:cols w:space=\"708\"/>\n" +
        "    </w:sectPr>";

        System.out.println(doc.getContent().replace("</w:body>", orientation + "\n</w:body>"));

    }

The piece of code that produces page orientation works if you add just before 
the end of the body. 

I will add this to the API later on...

If you don't know how to use the XML produced by doc.getContent() take a look 
at the Struts examples.

thanks
Leonardo

Original comment by leonardo...@gmail.com on 22 Dec 2010 at 10:19

GoogleCodeExporter commented 8 years ago
Thanks, I will keep you posted if I have any further issues

Original comment by udug...@gmail.com on 26 Dec 2010 at 9:16

GoogleCodeExporter commented 8 years ago
It will be implemented soon.

Original comment by leonardo...@gmail.com on 18 Mar 2011 at 1:27

GoogleCodeExporter commented 8 years ago
Finally implemented. Simple like that:

    IDocument doc = new Document2004();
    doc.setPageOrientationLandscape();

Remember that the default is always Portrait and don;t need to be specified.

cheers
Leonardo

Original comment by leonardo...@gmail.com on 19 Mar 2011 at 4:17

Attachments:

GoogleCodeExporter commented 8 years ago
Jar file in the download has been updated.

Original comment by leonardo...@gmail.com on 19 Mar 2011 at 4:29