Page 1 of 1

hyperlink style

PostPosted: Thu Aug 30, 2012 11:33 pm
by Timothy
Jason,

Is it correct that when I add a hyperlink in a docx file, this doesn't turn blue?
I am using the same code as the one in HyperlinkTest.java.

I saw a line saying: // TODO: enable this style in the document!
Maybe that's the reason ;-).
Can I implement this myself.

Thanx in advance!

Re: hyperlink style

PostPosted: Thu Aug 30, 2012 11:55 pm
by jason
You just need something like:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
                        ((WordprocessingMLPackage)wordMLPackage).getMainDocumentPart().getPropertyResolver().activateStyle(hyperlinkStyleId);
 
Parsed in 0.015 seconds, using GeSHi 1.0.8.4


(assuming your styles.xml file contains a style with id hyperlinkStyleId)

Re: hyperlink style

PostPosted: Fri Aug 31, 2012 12:35 am
by Timothy
Jason,

I put it in my code and it's working.
I also have a problem converting the document in attachment to PDF. I have searched over a day to find the solution, but nothing seems to help.

The document gets converted to a pdf, the google link in the document works, but the link I created myself (test) doesn't get converted. It's just not visible.
Do you have any idea what could be wrong.

In the log I see following error:

Code: Select all
ERROR [docx4j.model.PropertyResolver] Expected DefaultParagraphFont to have <w:basedOn ??


Thanx!

Re: hyperlink style

PostPosted: Sat Sep 01, 2012 8:57 pm
by jason
Your docx contains:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
    <w:p w:rsidRDefault="004F31AD" w:rsidR="004F31AD"/>
    <w:p>
      <w:pPr>
        <w:rPr>
          <w:noProof/>
        </w:rPr>
      </w:pPr>
      <w:r>
        <w:rPr>
          <w:noProof/>
        </w:rPr>
        <w:hyperlink r:id="rId9" w:history="true">
          <w:r>
            <w:rPr>
              <w:rStyle w:val="Hyperlink"/>
            </w:rPr>
            <w:t>test</w:t>
          </w:r>
        </w:hyperlink>
      </w:r>
    </w:p>
 
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


Notice that the w:hyperlink is inside a w:r. It shouldn't be; make it a child of w:p instead.

Re: hyperlink style

PostPosted: Mon Sep 03, 2012 10:48 pm
by Timothy
Jason,

I altered it in my code and it's working fine now!
Thanks a lot!

Timothy

Re: hyperlink style

PostPosted: Thu Oct 24, 2013 8:17 am
by rickfv
Hi friends,

I'm novice in docx4j. ¿How i can add style to link? Where should be the "styles.xml file that contains a style with id hyperlinkStyleId"? Thank you.